qq446152019
一个人瞎走
2017-11-02 07:41

Cannot forward after response has been committed

  • java

这是报错信息:
java.lang.IllegalStateException: Cannot forward after response has been committed
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:348)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.csair.filter.LoginTypeFilter.doFilter(LoginTypeFilter.java:104)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.csair.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:23)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

这是代码:
if ("app".equalsIgnoreCase(channel)) {// app登录
session.setAttribute("applogin", "1");
session.setAttribute("h5login", "0");
session.setAttribute("ordersource", "4");
request.setAttribute("domainpath", PublicVariable.URL_B2CTUANAPP);
// 如果是app访问h5连接,则重定向到app
if (!PublicVariable.URL_B2CTUANAPP.contains(req.getServerName())) {
HttpServletResponse res = (HttpServletResponse) response;// 向下转型
res.sendRedirect(PublicVariable.URL_B2CTUANAPP + req.getServletPath() + "?" + (req.getQueryString()));
return;
}
} else if ("h5".equalsIgnoreCase(channel)) {// h5登录
session.setAttribute("h5login", "1");
session.setAttribute("applogin", "0");
session.setAttribute("ordersource", "5");
request.setAttribute("domainpath", PublicVariable.URL_B2CTUAN);
}
chain.doFilter(request, response);

报错中,指明是104行报错,也就是chain.doFilter(request, response);我看了网上的文章,都说是因为重定向后没有写return,但是我明明写了,怎么还会一直报错呢

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换