如果页面/bb/a.jsp
假设我们有一个Filter的配置为:/bb/*,其中有一段代码为
if( need condition)
request.setAttribute("errormessage","The Error info.");
response.sendRedirect(ERROR_FOR_SOME_)
/if
在出错的页面不会看到预期的错误提示,
error_page.jsp
<c:out value="${errormessage}"></c:out>
Of course we cannot see any error info here,because of using the "sendRedirect"!!!
注意:redirect!!!修改为:
request.getRequestDispatcher(ERROR_FOR_SOME_).forward(request,response);
问题可解决
如果又在/bb/a.jsp页面中使用了:
<jsp:forward page="/some.jsp"/>
Error:Cannot forward after response has been committed
Redirect or Forward
最新推荐文章于 2022-02-25 18:19:43 发布