In our JSP pages, we use extensively. Works great, rewrites the URL to deal with sessionids, contexts, etc. But now we need to do some of this work inside a class that takes an HttpServletRequest and HttpServletResponse as part of the Spring Security specification.
How do I apply a 开发者_StackOverflowtype transformation to a path in a servlet? I guess I could reconstruct the URL with the scheme, host, port, context, path and query parameters (am I missing anything?). But I'd love a standard way to do this so I know it's being done properly.
The HttpServletResponse#encodeURL()
and HttpServletResponse#encodeRedirectURL()
deals with sessionids. The context can be obtained by HttpServletRequest#getContextPath()
.
精彩评论