当前位置: 代码迷 >> J2EE >> Action 里头报的错 求大神啦
  详细解决方案

Action 里头报的错 求大神啦

热度:70   发布时间:2016-04-17 23:26:45.0
Action 里面报的错 求大神啦
严重: Exception initializing page context
java.lang.IllegalStateException: Cannot create a session after the response has been committed




我写的action如下:

 @Action(value="addLog", results={
     @Result(name="success" ,location="/WEB-INF/pages/log/addlog.jsp")})
public String addLog(String userid) throws Exception{
personlogservice.addLog(userid);
return SUCCESS;
}


小弟跪谢了 加急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
------解决思路----------------------
问题分析:
之所以会出现此类问题是因为我们在Response输出响应后才创建Session的,因为那时候服务器已经将数据发送到客户端了,即:就无法发送Session ID 了

解决办法:
可以在struts.xml中添加一个默认的拦截器:
      <interceptor-ref name="createSession"/>
            <interceptor-ref name="defaultStack"/>

  相关解决方案