我想从Servlet的doPost方法调用PhaseListener。我该怎么做呢?
我不想这样做
RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/html/index.jsf"); dispatcher.forward(request, response);
因为在我的PhaseListener中,我正在检查viewId。按照上面的方法,视图id始终保持为index.xtml。所以,我不能检查我的状况。
发布于 2012-08-30 16:37:43
您使用的转发不会启动新请求,因此您将保留原始请求URI。您需要做一个重定向,它会启动一个新请求,并为您提供新的请求URI。所以需要使用:
response.sendRedirect("/jsp/html/index.jsf");请注意,response.sendRedirect()会将status设置为302。如果您需要301状态,则需要使用:
response.setStatus(301);
response.setHeader("Location", "/jsp/html/index.jsf");https://stackoverflow.com/questions/12162486
复制相似问题