异常:java.lang.IllegalArgumentException: Control character in cookie value or attribute.
后臺提示:
嚴重: Error processing request
java.lang.IllegalArgumentException: Control character in cookie value or attribute.
at org.apache.tomcat.util.http.CookieSupport.isV0Separator(CookieSupport.java:165)
at org.apache.tomcat.util.http.Cookies.processCookieHeader(Cookies.java:349)
at org.apache.tomcat.util.http.Cookies.processCookies(Cookies.java:176)
at org.apache.tomcat.util.http.Cookies.getCookieCount(Cookies.java:106)...
————————————————————————————————————————————————————\
項目簡述:在js中操作cookie時出現的異常(Jquery中依然能用)
基本代碼如下:(已修改)
if("Administrator"==result.data.username){//管理員設計document.cookie="username="+escape('系統管理員');// $.cookie('username','系統管理員');}else{//普通員工設計 document.cookie="username="+escape(result.data.username); document.cookie="postId="+result.data.postId;//職務Id document.cookie="induction_time="+result.data.induction_time;//入職時間document.cookie="monthlyleave="+result.data.monthlyleave;//當月假期 }document.cookie="userId="+result.data.id;// document.cookie="identification="+result.data.identification;//標記異常分析:
1.cookie值有問題
2.cookie中編碼有問題,一般都是中文那里
修改:在js中調用escape(“中文”),進行編碼,
在讀取cookie時,用unescape(document.cookie);進行解碼
補充:
有的是在服務器端代碼遇到的問題,請到服務器端去修改編碼(服務器端不用escape)。
轉載于:https://www.cnblogs.com/wx-ym-good/p/7630394.html
總結
以上是生活随笔為你收集整理的异常:java.lang.IllegalArgumentException: Control character in cookie value or attribute.的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 23款科鲁泽湿式双离合怎么样?
- 下一篇: 国六标准实施之后,买车的成本会有哪些变化