我有一个页面说:/myapp/test.jsp?queryString=Y.
过滤器需要重定向到当前页面.
它应该转到/myapp/test.jsp(没有查询字符串).
以下似乎将它带到了上下文根:/ myapp.
我在WAS6.1中运行.
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpReq = (HttpServletRequest) req;
HttpServletResponse httpResp = (HttpServletResponse) resp;
{
boolean blnNeedToRedirect = true;
if (blnNeedToRedirect) {
httpResp.sendRedirect(".");
return;
}
chain.doFilter(req, resp);
}
解决方法:
httpResp.sendRedirect(httpReq.getRequestURI());
标签:java,redirect,servlet-filters
来源: https://codeday.me/bug/20190726/1547467.html