【发布时间】:2009-12-17 14:27:17
【问题描述】:
我想将请求从 JSF 操作方法转发到非 JSF 页面。 我在我的 JSF 操作中使用以下代码:
public String submitUserResponse() {
// ...
parseResponse("foo.jsp", request, response);
// ...
return "nextpage";
}
private String parseResponse(String uri, HttpServletRequest request, HttpServletResponse response) {
if (uri != null) {
RequestDispatcher dispatcher = request.getRequestDispatcher(uri);
dispatcher.forward(request, response);
return null;
}
// ...
return "xxxx";
}
submitUserResponse() 操作方法在用户单击 JSF 页面中的提交按钮时被调用,并且此方法返回 nextpage 字符串。这里请求以正常流程转发到下一个 JSF 页面。但在我的要求中,我需要将请求转发到下一个非 JSF 页面。它正在运行,但它在服务器中显示在异常下方。
java.lang.IllegalStateException: 响应提交后无法转发
我观察到在使用dispatched.forward(uri) 转发我的请求后,parseResponse(...) 和return "nextpage"; 之间的代码行仍在执行。 response.sendRedirect(url) 也发生了同样的事情。这是如何引起的,我该如何解决?
【问题讨论】:
标签: jsf navigation forward