读书人

Cannot create a session after the r

发布时间: 2013-01-11 11:57:35 作者: rapoo

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方式请求 那么方法是不是不应该有返回值啊

读书人网 >J2EE开发

热点推荐