Skip to content

Commit

Permalink
GRAILS-10448 - replace WebUtils.exposeForwardRequestAttributes which …
Browse files Browse the repository at this point in the history
…was removed from Spring 4
  • Loading branch information
Jeff Scott Brown committed Sep 16, 2013
1 parent 1be0fd3 commit 4364239
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static String forwardRequestForUrlMappingInfo(HttpServletRequest request,
@SuppressWarnings({ "unchecked", "rawtypes" })
public static String forwardRequestForUrlMappingInfo(HttpServletRequest request,
HttpServletResponse response, UrlMappingInfo info, Map model, boolean includeParams) throws ServletException, IOException {
// exposeForwardRequestAttributes(request);
exposeForwardRequestAttributes(request);
exposeRequestAttributes(request, model);

String forwardUrl = buildDispatchUrlForMapping(info, includeParams);
Expand All @@ -323,6 +323,27 @@ public static String forwardRequestForUrlMappingInfo(HttpServletRequest request,
dispatcher.forward(request, response);
return forwardUrl;
}

/**
* Expose the current request URI and paths as {@link javax.servlet.http.HttpServletRequest}
* attributes under the keys defined in the Servlet 2.4 specification,
* for containers that implement 2.3 or an earlier version of the Servlet API:
* {@code javax.servlet.forward.request_uri},
* {@code javax.servlet.forward.context_path},
* {@code javax.servlet.forward.servlet_path},
* {@code javax.servlet.forward.path_info},
* {@code javax.servlet.forward.query_string}.
* <p>Does not override values if already present, to not cause conflicts
* with the attributes exposed by Servlet 2.4+ containers themselves.
* @param request current servlet request
*/
public static void exposeForwardRequestAttributes(HttpServletRequest request) {
exposeRequestAttributeIfNotPresent(request, FORWARD_REQUEST_URI_ATTRIBUTE, request.getRequestURI());
exposeRequestAttributeIfNotPresent(request, FORWARD_CONTEXT_PATH_ATTRIBUTE, request.getContextPath());
exposeRequestAttributeIfNotPresent(request, FORWARD_SERVLET_PATH_ATTRIBUTE, request.getServletPath());
exposeRequestAttributeIfNotPresent(request, FORWARD_PATH_INFO_ATTRIBUTE, request.getPathInfo());
exposeRequestAttributeIfNotPresent(request, FORWARD_QUERY_STRING_ATTRIBUTE, request.getQueryString());
}

/**
* Include whatever the given UrlMappingInfo maps to within the current response
Expand Down

0 comments on commit 4364239

Please sign in to comment.