can not create a session after response is commited
来源:互联网 发布:北京索顿网络是培训吗 编辑:程序博客网 时间:2024/06/12 21:45
can not create a session after response is commited
这个错误一般在本地难以发生,部署到服务器上回发生。
1.getsession()放在了response提交后面
2.getssion(true),没有session会创建session,访问量稍大时,在多线程环境,单例模式下(Spring默认创建bean的单例的,做权限管理用拦截器时,HandlerInterceptor也是单例),可能会出现response提交了,session再创建,因此不能用true
3.response返回数据是有缓存限制的,具体参考下面文章,当缓存超出限制是就会自动提交的
You shouldn't be doing business job in getters. Do it in the bean (post)constructor instead.
Your concrete problem is caused because you're requesting a relatively large page on a fresh new browser session for which the server HttpSession
hasn't been created yet and the EL expression #{equityBean.scripList}
is referenced relatively late in the page.
The response buffer is by default 2KB and when it overflows due to a large response, then it will be committed. This means that all response headers will be sent and that first ~2KB of the HTML output will be sent. Then, after that point, the EL expression #{equityBean.scripList}
will be resolved wherein you're trying to get the session. If the server HttpSession
hasn't been created yet at that moment, then the server needs to set a cookie in the response header in order to maintain it for subsequent requests. But that's of course not possible if the response has already been committed. Hence this exception.
As said, just do the job in bean's (post)constructor instead. Or just inject it as managed property.
@ManagedProperty("#{type}")private String type;
------https://stackoverflow.com/questions/10949556/cannot-create-session-after-response-has-been-committed。 - can not create a session after response is commited
- Cannot create a session after the response has been committed
- Cannot create a session after the response has been committed
- Cannot create a session after the response has been committed
- Cannot create a session after the response has been committed
- Cannot create a session after the response has been committed
- Cannot create a session after the response has been committed
- Sturts2异常:Cannot create a session after the response has been committed
- java.lang.IllegalStateException: Cannot create a session after the response has been committed
- java.lang.IllegalStateException: Cannot create a session after the response has been committed
- Cannot create a session after the response has been committed错误的原因
- Struts2 Cannot create a session after the response has been committed 一个不起眼的错误
- Cannot create a session after the response has been committed 响应提交后无法创建会话
- CAS-ERR Cannot create a session after the response has been committed
- java.lang.IllegalStateException: Cannot create a session after the response has been committed
- java.lang.IllegalStateException: Cannot create a session after the response has been committed
- Server报错:java.lang.IllegalStateException: Cannot create a session after the response has been commit
- java.lang.IllegalStateException: Cannot create a session after the response has been committed
- 状态栏的使用
- 【学术】矩阵&特征值:如果知道同阶矩阵A,B的特征值,A+B的特征值是A和B特征值的和吗?
- C++学习笔记--函数模板
- 实用网址链接
- apt-get update失败处理
- can not create a session after response is commited
- 搞科研(时序信号)
- 【学习笔记】字符串和编码
- Java递归实现输入任意目录,列出文件以及文件夹
- 542. 01 Matrix
- 机器学习作业9
- Java 的 多态
- ResourceExhaustedError: OOM when allocating tensor with shape[10,256,400,528]
- LeetCode-020 Valid Parentheses