首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

Cannot create a session after the response has been committed解决办法

2013-01-11 
Cannot create a session after the response has been committedjava.lang.IllegalStateException: Canno

Cannot create a session after the response has been committed
java.lang.IllegalStateException: Cannot create a session after the response has been committed我的action报这样一个错,action里面内容是 
public String getTree()throws Exception{

HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("utf-8");
response.setContentType("application/json;charset=utf-8");
                。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 
JSONArray  json = JSONArray.fromObject(hospitalList);
PrintWriter out = response.getWriter();
out.print(json.toString());
out.flush();
out.close();
System.out.println(json.toString());

return SUCCESS;

}
请高手指点下为什么会报这个错,应该怎么改,省略的部分只是获取到的一个BEAN
[解决办法]
楼主既然用response像页面传递数据  应该是用的ajax方式请求  那么方法是不是不应该有返回值啊

热点排行
Bad Request.