HttpSession 存储验证码失败
2015-09-18 10:55
615 查看
try { RandomValidateCode randomValidateCode = new RandomValidateCode(); String randomString = randomValidateCode.getRandcode(req, resp);//输出图片方法 // Cannot create a session after the response has been committed HttpSession session = req.getSession(); session.setAttribute(RandomValidateCode.RANDOMCODEKEY, randomString); } catch (Exception e) { logger.error(e.getMessage(), e); }
如上生成并且存储验证码的代码,在登录页面 url 不输工程名的时候(如 http://127.0.0.1:7878/),会报异常 Cannot create a session after the response has been committed
因此需要把 session.setAttribute(RandomValidateCode.RANDOMCODEKEY, randomString); 在 response 写成验证码图片前执行
相关文章推荐
- UI一揽子计划 16 (网络编程、HTTP协议、iOS 实现网络编程、服务器接口)
- TCP通信的建立断开和状态转移
- http://segmentfault.com/a/1190000000683599神器——Chrome开发者工具(一)
- AJAX跨域访问
- HTTP请求返回状态码中301与302的状态码区别
- HttpServletResponse,HttpServletRequest详解
- iOS实用技巧 - AFNetworking2安全的使用自签证书访问HTTPS
- TCP/IP阻塞控制机制
- 关于Xcode7的一些改变
- Linux下用tcpdump抓包,wireshark可视化
- iOS9 HTTP 不能正常使用的解决办法
- C# HttpWebRequest HttpWebReponse 挂起无反应,阻塞解决方案
- centos 命令 设置网络IP方法
- 从零认识tomcat,构建一机多实例tomcat集群 - My---Dream.* - 51CTO技术博客 http://grass51.blog.51cto.com/4356355/1123400
- TCP/IP的工作原理
- Android性能优化(四),网络优化 && 耗电量优化
- HTTP/1.1协议中共定义了八种方法
- Xcode升级到7以后网络请求失败的问题
- 流压缩技术 减少网络传输字节
- 在iOS9中,苹果将原http协议改成了https协议,使用 TLS1.2 SSL加密请求数据。如何解决报错