java.lang.IllegalStateException:PWC1227:响应提交后无法转发.....为什么会这样做? [英] java.lang.IllegalStateException: PWC1227: Cannot forward after response has been committed.....why it was comming?

查看:998
本文介绍了java.lang.IllegalStateException:PWC1227:响应提交后无法转发.....为什么会这样做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将一些行数据添加到表中,提交提交按钮,我必须在该表的下一页中显示详细信息(数据)。当我使用 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆