java.lang.IllegalStateException:PWC1227:响应提交后无法转发.....为什么会这样做? [英] java.lang.IllegalStateException: PWC1227: Cannot forward after response has been committed.....why it was comming?
问题描述
将一些行数据添加到表中,提交提交按钮,我必须在该表的下一页中显示详细信息(数据)。当我使用 RequestDispather
类时,我得到 java.lang.IllegalStateException:
........使用 response.sendRedirect(View.jsp);
.....我正在发送我在页面中使用的代码。
to add some row data into a table, affter submmiting the button i have to show the details(data) in the next page of that regarding table. when i am using RequestDispather
class i am getting the java.lang.IllegalStateException:
........ it was also comming while using response.sendRedirect("View.jsp");
..... i am sending the code what i used in my page.
if(msg.equals("Values Added")){
RequestDispatcher rd = request.getRequestDispatcher("View.jsp");
rd.forward(request, response);
}
(OR)
if(msg.equals("Values Added")){
response.sendRedirect("View.jsp");
}
推荐答案
以下是不正确的se:
你不能从JSP里面改变这样的回复,现在太晚了。
"You cannot change the response like that from inside a JSP. It's too late then."
只需将你的回发检查和重定向到您的jsp中的html标签之前,那么一切都会很好。
Just place your postback check and redirect before the html tag in your jsp...then everything will be fine.
所以:
<% if(msg.equals("Values Added")){
response.sendRedirect("View.jsp");
} %>
< html> ...< / html>
这篇关于java.lang.IllegalStateException:PWC1227:响应提交后无法转发.....为什么会这样做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!