java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value

今天在练习 cookie时意外的报了这个错。

java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value
1
这句话的意思是
一个不识别的字符[32]出现在了cookie当中
由于tomcat的版本比较高,所以在addCookie时是不能使用空格的 而在ASCII码中32对应的就是空格。只要把后台代码中的空格删掉就可以了。
我的代码:是在cookie中添加了时间,而时间的格式化中我是用了format。上代码:

光标所在之处,这里的天和小时之间用的是空格分隔,所以会报错。

只要将这个空格修改掉就可以了。比如改成 -
问题解决

原文地址:https://www.cnblogs.com/AEtudo/p/10463468.html

时间: 2024-11-08 09:43:31

java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value的相关文章

cookie设置日期时间有空格报错:java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value

rt,代码及报错如下: java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value 现暂时将"yyyy-MM-dd hh:mm:ss"中的空格用#替代,就能正常显示时间日期了...

【Cookie】java.lang.IllegalArgumentException An invalid character [32] was present in the Cookie value

创建时间:6.30 java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value 报错原因: Tomcat 8.5版本,在cookie值中不能使用空格. 代码: 1 protected void doGet(HttpServletRequest request, HttpServletResponse response) 2 throws ServletException

An invalid character [32] was present in the Cookie value

HTTP Status 500 – Internal Server Error Type Exception Report Message An invalid character [32] was present in the Cookie value Description The server encountered an unexpected condition that prevented it from fulfilling the request. Exception java.l

Spring Boot报错:java.lang.IllegalArgumentException: An invalid character [..] was present in the Cookie value

原因及解决办法:https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/reference/htmlsingle/#howto-use-tomcat-legacycookieprocessor @Configuration public class CookieConfig { /** * 解决问题: * There was an unexpected error (type=Internal Server Error, status=500)

java中Cookie使用问题(message:invalid character [32] was present in the Cookie value)

1. 问题描述 Servlet中执行下面一段代码: public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=utf-8"); System.out.println( new Date().toString()); Cookie c

java.lang.IllegalArgumentException: An invalid domain [.test.com] was specified for this cookie

https://blog.csdn.net/cml_blog/article/details/52135115 当项目中使用单点登录功能时,通常会使用cookie进行信息的保存,这样就可以在多个子域名上存取用户信息. 比如有三个domain分别为test.com,cml.test.com,b.test.com这三个域名下的cookie是需要互相访问的.这时会在response上写入cookie信息 Cookie cookie = new Cookie("testCookie", &qu

java.lang.IllegalArgumentException: sheetName '' is invalid

1.错误描写叙述 java.lang.IllegalArgumentException: sheetName '' is invalid - character count MUST be greater than or equal to 1 and less than or equal to 31 at org.apache.poi.ss.util.WorkbookUtil.validateSheetName(WorkbookUtil.java:135) at org.apache.poi.h

java.lang.IllegalArgumentException: sheetName '' is invalid

1.错误描述 java.lang.IllegalArgumentException: sheetName '' is invalid - character count MUST be greater than or equal to 1 and less than or equal to 31 at org.apache.poi.ss.util.WorkbookUtil.validateSheetName(WorkbookUtil.java:135) at org.apache.poi.hss

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

1 HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: Control character in cookie value or attribute. 2 type Exception report 3 4 message Request processing failed; nested exception is java.lang.Illega