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).
     * An invalid domain [.localhost.com] was specified for this cookie
     *
     * @return
     */
    @Bean
    public WebServerFactoryCustomizer<TomcatServletWebServerFactory> cookieProcessorCustomizer() {
        return (factory) -> factory.addContextCustomizers(
                (context) -> context.setCookieProcessor(new LegacyCookieProcessor()));
    }
}

补充cookie坑,同一个服务器,前端访问IP地址cookie存在IP地址下,访问域名cookie存在域名下

原文地址:https://www.cnblogs.com/yxmhl/p/12237343.html

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

Spring Boot报错:java.lang.IllegalArgumentException: An invalid character [..] 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"中的空格用#替代,就能正常显示时间日期了...

反射报错java.lang.IllegalArgumentException: wrong number of arguments

class Person{ private String name ; private String sex ; public Person(){ System.out.println("c"); } public Person(String c1){ this.name =c1; System.out.println("c1"+c1); } public Person(String c1,String c2){ this.name =c1; this.sex =c

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 value1这句话的意思是 一个不识别的字符[32]出现在了cookie当中 由于tomcat的版本比较高,所以在addCookie时是不能使用空格的 而在ASCII码中32对应的就是空格.只要把后台代码中的空格删掉就可以了. 我的代码:是在cookie中添加了时间,而时间的格

【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

tomcat报错java.lang.IllegalArgumentException: Document base XXXXX does not exist or is not a readable directory

启动tomcat的时候报如下错误: java.lang.IllegalArgumentException: Document base F:\java\tools\tomcat\me-webapps\drp1.1 does not exist or is not a readable directory     at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)    at org.a

【实战问题】【5】Spring boot报错java.awt.HeadlessException

解决方案: 1,在入口类里修改成以下代码,其中YourApplication改成你的入口类的名字 SpringApplicationBuilder builder = new SpringApplicationBuilder(YourApplication.class); builder.headless(false).web(false).run(args); 2,在VM的Option里加上一句-Djava.awt.headless=false.然后启动 参考博客: Spring boot出现

升级tomcat之后,页面报错java.lang.IllegalArgumentException: Page directive: invalid value for import

仔细检查发现是<%@ page import=" java.util.*;"%>一句引起的错误. 把<%@ page import=" java.util.*;"%>中的分号去掉就好了,改为: <%@ page import=" java.util.*"%> 所以以后写import要规范. 项目中可能还有多处这种问题,大部分情况是开发人员写代码太随意的原因.

mybatis报错: java.lang.IllegalArgumentException invalid comparison: java.util.Date and java.lang.String

原因是在使用<if> 进行条件判断时, 将datetime类型的字段与 ' ' 进行了判断,导致的错误 解决, 只使用  <if test="createTime != null"></if> 做判断就行了 详细可参考: https://blog.csdn.net/wanghailong_qd/article/details/50673144 原文地址:https://www.cnblogs.com/gczmn/p/11880972.html

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