jsp+servlet跳转问题: Cannot call sendRedirect() after the response has been committed开始先访问jsp页面,判断是否能够拿到session,拿不到就重定向到servlet,servlet拿到之后再重定向到jsp.问题:执行到jsp的if(goodsInfo

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/09 11:50:13
jsp+servlet跳转问题: Cannot call sendRedirect() after the response has been committed开始先访问jsp页面,判断是否能够拿到session,拿不到就重定向到servlet,servlet拿到之后再重定向到jsp.问题:执行到jsp的if(goodsInfo

jsp+servlet跳转问题: Cannot call sendRedirect() after the response has been committed开始先访问jsp页面,判断是否能够拿到session,拿不到就重定向到servlet,servlet拿到之后再重定向到jsp.问题:执行到jsp的if(goodsInfo
jsp+servlet跳转问题: Cannot call sendRedirect() after the response has been committed


开始先访问jsp页面,判断是否能够拿到session,拿不到就重定向到servlet,servlet拿到之后再重定向到jsp.问题:执行到jsp的

if(goodsInfos==null){

response.sendRedirect("GoodsInfo_con?function=goodsList");

}这个if就抛异常了: Cannot call sendRedirect() after the response has been committed

.servlet都进不去了.在线求解


上面的图是jsp
下面的是servlet

jsp+servlet跳转问题: Cannot call sendRedirect() after the response has been committed开始先访问jsp页面,判断是否能够拿到session,拿不到就重定向到servlet,servlet拿到之后再重定向到jsp.问题:执行到jsp的if(goodsInfo
哎,不知道在说什么啊.
不过看起来是你在页面用了response.sendRedirect() .你之前的代码是不是有跳转啊?
在页面提交,你可以用javascript啊.可以用form的submit();

这个提示就是说,你response已经提交了不能在用函数sendRedirect() ,可以尝试别的跳转方法