本地测试通过的程序部署到测试环境遇到一个问题,如果登陆名称为中文时将引发如下所示的异常,而英文字母或者数字的登陆名称则是正常的,异常信息如下:
java.lang.IllegalArgumentException: Control character in cookie value or attribute. at org.apache.tomcat.util.http.CookieSupport.isV0Separator(CookieSupport.java:155) at org.apache.tomcat.util.http.Cookies.processCookieHeader(Cookies.java:323) at org.apache.tomcat.util.http.Cookies.processCookies(Cookies.java:157) at org.apache.tomcat.util.http.Cookies.getCookieCount(Cookies.java:98) at org.apache.catalina.connector.CoyoteAdapter.parseSessionCookiesId(CoyoteAdapter.java:913) at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:683) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:400) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
根据上述异常提示检查代码,在本地重复测试了N次,发现一切正常,异常始终无法在本地重现,后来才发现测试服务器环境与本地开发环境不一样,测试服务器Tomcat为7.0版本,而本地开发环境tomcat为6.0,环境不统一就会出现各种千奇百怪的异常,在此提醒大家开发环境、测试、正式环境软件版本一定要统一!!!
还上Tomcat7之后再次测试,异常终于重现,通过调试发现由于在登陆的时候需要使用Cookie来保存用户的登陆信息,而Tomcat7中cookie对中文的支持不够好,直接将中文字符的登陆名写入cookie时会引发异常,所以需要先转码,才不会出现上述的异常。
正常写入不算完事,因为此时后台解析cookie值的代码取到的值是乱码,使用cookie是无法登陆的;这就需要在后台验证cookie登陆时,得先将取得到的cookie值转成UTF-8格式之后在对比数据库确认登陆信息是否正确。
相关推荐
由于原本把需要的数据存放到cookie中,但是cookie不能的key不能自动转译中文,出现乱码,后台服务器报错:Control character in cookie value or attribute.所以改为自定义map集合
基于属性的访问控制模型及其展望Attribute-Based Access Control Models and Beyond 云计算
最新tomcat7+nginx/tengine+memcached共享session的jar包2016年12月自己更新使用,更新的jar包解决了tomcat7下attribute报错的问题,理论Tomcat8以上版本可用,请自己测试。 asm-5.1.jar kryo-4.0.0.jar kryo-...
Attribute-Based and Value-Based Clustering An Evaluation
Attribute Value Weighting in K-Modes Clustering,何增友,,In this paper, the traditional k-modes clustering algorithm is extended by weighting attribute value matches in dissimilarity computation....
In order to help mitigate the risk of cross-site scripting, a new feature has been introduced in Microsoft Internet Explorer 6 SP1. This feature is a new attribute for cookies which prevents them from...
Laravel开发-entity-attribute-value-model Laravel的实体-属性-价值模型(EAV)
支持协作的基于属性访问控制,李梦婷,黄欣沂,本文介绍了一种为企业计算系统设计的 支持协作的基于属性访问控制机制。该系统中用户被划分为不同的群体,且都关联着不同的属性。�
Pedestrian Attribute Recognition with Graph Convolutional Network in Surveillance Scenarios
Attribute在NET中的应用 讲解在NET中如何自定义自己的特性(Attribute)如何使用
本文实例讲述了jQuery中[attribute^=value]选择器用法。分享给大家供大家参考。具体分析如下: 此选择器能够选取属性值是以某些值开始的元素。 语法结构: 代码如下:$(“[attribute^=value]”) 参数列表: 参数 ...
Pose guided deep model for pedestrian attribute recognition in surveillance scenarios
包含2篇attribute高级应用文章,以及相应的代码。 代码关键处,都有详细注释。 看过后,你会对attribute,context有更深刻的认识
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists. getAttribute(String) - Method in interface javax.servlet.http.HttpSession Returns the object ...
python3 server.py 127.0.0.1 8888 ...AttributeError: module ‘os’ has no attribute ‘exit’ 部分代码入下: from socket import * import sys,os #实现登录 def do_login(s,user,name,addr): for i in user: i
Multiple Attribute Decision Making with Incomplete Weight Information in Linguistic Setting,卫贵武,,The aim of this paper is to investigate the multiple attribute decision making problems with ...
主要介绍了jQuery中[attribute=value]选择器用法,实例分析了[attribute=value]选择器的功能、定义及给定属性及属性值元素的使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下
读了《Attribute在.net编程中的应用》,对Attribute的认识会加深,对编程很有帮助哦!
GNU_CC中的attribute有助于你对于gnu c中的内容深入理解
A New Role-Based Access Control Model Using Attribute Certificate.pdf