欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-10-25 08:50:50
IllegalArgumentException此异常表明向方法传递了一个不合法或不正确的参数 注意Control character in cookie value or attribute 这个才是重点 问题说明Cookie编码格式错误 解决办法cookie存储值是指明utf8国际编码格式 如 ......
 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.IllegalArgumentException: Control character in cookie value or attribute.
 5 
 6 description The server encountered an internal error that prevented it from fulfilling this request.
 7 
 8 exception
 9 
10 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Control character in cookie value or attribute.
11     org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
12     org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
13     javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
14     org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
15     javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
16     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
17     org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
18     org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
19 root cause
20 
21 java.lang.IllegalArgumentException: Control character in cookie value or attribute.
22     org.apache.tomcat.util.http.CookieSupport.isHttpSeparator(CookieSupport.java:205)
23     org.apache.tomcat.util.http.CookieSupport.isHttpToken(CookieSupport.java:229)
24     org.apache.tomcat.util.http.ServerCookie.appendCookieValue(ServerCookie.java:185)
25     org.apache.catalina.connector.Response.generateCookieString(Response.java:1054)
26     org.apache.catalina.connector.Response.addCookie(Response.java:996)
27     org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:380)
28     admin.membersheep.hk.Controller.HomeController.Login(HomeController.java:327)
29     sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
30     sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
31     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
32     java.lang.reflect.Method.invoke(Method.java:498)
33     org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220)
34     org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
35     org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
36     org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
37     org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
38     org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
39     org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
40     org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
41     org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
42     org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
43     javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
44     org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
45     javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
46     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
47     org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
48     org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
49 note The full stack trace of the root cause is available in the Apache Tomcat/7.0.85 logs.

 IllegalArgumentException此异常表明向方法传递了一个不合法或不正确的参数

注意Control character in cookie value or attribute 这个才是重点

问题说明Cookie编码格式错误

解决办法cookie存储值是指明utf8国际编码格式

javax.servlet.http.Cookie realCookie = new javax.servlet.http.Cookie(java.net.URLEncoder.encode(temp.getName(),"utf8"),java.net.URLEncoder.encode(temp.getValue(),"utf8"));

  未经同意请勿转载!!!

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