调用Cookie对象的构造函数可以创建Cookie。Cookie对象的构造函数有两个字符串参数:Cookie名字和Cookie值。 
  名字和值都不能包含空白字符以及下列字符:[ ] ( ) < > = , " / ? @ : ;

错误出在response.addCookie(cookie);//cookie 是一个Cookie实例。

J2EE Doc里面的,cookies只支持ASCII字符,而且不能有逗号,分号,
空白。或者以$开头。名字在创建后不能改变。如果要存储中文的,先用URLEcode编码,在存入,取出的时候,用decode解码。

在保存cookie之前把值编码下:

URLEncoder.encode(cookieValue, "UTF-8");

取cookie值时解码:

URLDecoder.decode(localCookieValue, "UTF-8");

创建Cookie抛出异常:java.lang.IllegalArgumentException: Control character in cookie value的更多相关文章

  1. cookie遇到java.lang.IllegalArgumentException: Control character in cookie value or attribute

    java.lang.IllegalArgumentException: Control character in cookie value or attribute. 该异常说明cookie中的val ...

  2. Cookie存储中文报错:java.lang.IllegalArgumentException: Control character in cookie value or attribute.(转)

    项目中做自动登录和保存密码时,Cookie报错Java.lang.IllegalArgumentException,上google查了下 在http://hi.baidu.com/xtxycy/blo ...

  3. tomcat使用cookies缓存的时候中文报错解决办法 java.lang.IllegalArgumentException: Control character in cookie value or attribute.

    报错出现 java.lang.IllegalArgumentException: Control character in cookie value or attribute. at org.apac ...

  4. 异常:java.lang.IllegalArgumentException: Control character in cookie value or attribute.

    后台提示: 严重: Error processing requestjava.lang.IllegalArgumentException: Control character in cookie va ...

  5. HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: Control character in cookie value or attribute.

    HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: ...

  6. 在浏览器访问Tomcat的时候报错java.lang.IllegalArgumentException: Control character in cookie value or attribute.

    出现这种情况的原因就是因为cookie中存在中文或者特殊符号造成的,应为Tomcat7不支持 解决方法: 1,首先必须先删除本地的cookie,否则项目无法访问 2,然后调整编码就行了

  7. 解决Tomcat的IllegalArgumentException: Control character in cookie value or attribute错误

    接口中带有中文,tomcat8 17-Apr-2019 13:21:23.734 严重 [http-nio-8082-exec-2] org.apache.coyote.http11.Abstract ...

  8. java.lang.IllegalArgumentException: Illegal character in query at index 261

    在BaseFragment中使用了LoadingPage,而LoadingPage的联网加载使用的是AsyncHttpClient.一直报java.lang.IllegalArgumentExcept ...

  9. Tomcat v7.0 java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

    十二月 , :: 下午 org.apache.coyote.http11.AbstractHttp11Processor process 信息: Error parsing HTTP request ...

随机推荐

  1. JS里的居民们6-数组排序

    编码 var arr = [43, 54, 4, -4, 84, 100, 58, 27, 140]; 将上面数组分别按从大到小以及从小到大进行排序后在console中输出 var arr = ['a ...

  2. StringBuffer总结分析

    构造方法 /** * Constructs a string buffer with no characters in it and an * initial capacity of 16 chara ...

  3. BZOJ2882: 工艺(后缀数组)

    题意 题目链接 Sol 直接把序列复制一遍 后缀数组即可 在前\(N\)个位置中取\(rak\)最小的输出 #include<bits/stdc++.h> using namespace ...

  4. 初识shell expect

    场景:工作中经常会遇到shell脚本写的连接脚本,所以稍微了解下. 一.shell Shell 是一个用C语言编写的程序,它是用户使用Linux的桥梁.Shell既是一种命令语言,又是一种程序设计语言 ...

  5. replace的坑

    问题:html中代码段包含了$,在使用replace替换时,$直接被替换了解决:先把文本中的$全部替换成自己定义的标签,最后在还原回去原因:在介绍replace的文档中,$&代表插入匹配的子串 ...

  6. 移动端开发:iOS与Android平台上问题列表

    要CSS伪类 :active 生效,只需要给 document 绑定 touchstart 或 touchend 事件 <style> a { color: #000; } a:activ ...

  7. chrome 控制台里 打印对象

    我们经常使用 chrome 的 控制台 console.log()     打印 但有时候我们需要把一个对象复制下来(而这个对象嵌套比较深) 打印出来的我们不好复制 如下图 我们可以使用谷歌控制台的c ...

  8. 简单理解C#中的抽象工厂模式是什么概念!

    抽象工厂模式向客户端提供一个接口,使得客户端在不必指定具体类型的情况下,创建多个产品族中的对象.本文采取的仍然是接着以前的那个快餐店的例子.现在,快餐店经常良好,逐渐发展壮大,为了适合不同地方人的饮食 ...

  9. [转]ggplot2用法简单介绍

    简介 ggplot2包是基于Wilkinson在<Grammar of Graphics>一书中所提出的图形语法的具体实现, 这套图形语法把绘图过程归纳为data, transformat ...

  10. css tips: 清除float影响,containing的div跟随floated sub等

    /** * For modern browsers * 1. The space content is one way to avoid an Opera bug when the * content ...