Skip to content

Commit b17d53f

Browse files
committed
DispatcherPortlet uses a forward for rendering a view as resource response
Issue: SPR-9876
1 parent 7f081a5 commit b17d53f

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/DispatcherPortlet.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import javax.portlet.MimeResponse;
3333
import javax.portlet.PortletException;
3434
import javax.portlet.PortletRequest;
35+
import javax.portlet.PortletRequestDispatcher;
3536
import javax.portlet.PortletResponse;
3637
import javax.portlet.PortletSession;
3738
import javax.portlet.RenderRequest;
@@ -1158,8 +1159,8 @@ protected View resolveViewName(String viewName, Map model, PortletRequest reques
11581159
* {@link org.springframework.web.servlet.ViewRendererServlet}.
11591160
* @param view the View to render
11601161
* @param model the associated model
1161-
* @param request current portlet render request
1162-
* @param response current portlet render response
1162+
* @param request current portlet render/resource request
1163+
* @param response current portlet render/resource response
11631164
* @throws Exception if there's a problem rendering the view
11641165
*/
11651166
protected void doRender(View view, Map model, PortletRequest request, MimeResponse response) throws Exception {
@@ -1170,8 +1171,28 @@ protected void doRender(View view, Map model, PortletRequest request, MimeRespon
11701171
request.setAttribute(ViewRendererServlet.VIEW_ATTRIBUTE, view);
11711172
request.setAttribute(ViewRendererServlet.MODEL_ATTRIBUTE, model);
11721173

1173-
// Include the content of the view in the render response.
1174-
getPortletContext().getRequestDispatcher(this.viewRendererUrl).include(request, response);
1174+
// Include the content of the view in the render/resource response.
1175+
doDispatch(getPortletContext().getRequestDispatcher(this.viewRendererUrl), request, response);
1176+
}
1177+
1178+
/**
1179+
* Perform a dispatch on the given PortletRequestDispatcher.
1180+
* <p>The default implementation uses a forward for resource requests
1181+
* and an include for render requests.
1182+
* @param dispatcher the PortletRequestDispatcher to use
1183+
* @param request current portlet render/resource request
1184+
* @param response current portlet render/resource response
1185+
* @throws Exception if there's a problem performing the dispatch
1186+
*/
1187+
protected void doDispatch(PortletRequestDispatcher dispatcher, PortletRequest request, MimeResponse response)
1188+
throws Exception {
1189+
1190+
if (PortletRequest.RESOURCE_PHASE.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE))) {
1191+
dispatcher.forward(request, response);
1192+
}
1193+
else {
1194+
dispatcher.include(request, response);
1195+
}
11751196
}
11761197

11771198

0 commit comments

Comments
 (0)