HTTP Status 500 - Request processing failed; nested exception is

HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: Control character in cookie value or attribute.
 type Exception report
 
 message Request processing failed; nested exception is java.lang.IllegalArgumentException: Control character in cookie value or attribute.
 
 description The server encountered an internal error that prevented it from fulfilling this request.
 
 exception
 
 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Control character in cookie value or attribute.
     org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
     org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
     org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
     org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
     org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 root cause
 
 java.lang.IllegalArgumentException: Control character in cookie value or attribute.
     org.apache.tomcat.util.http.CookieSupport.isHttpSeparator(CookieSupport.java:205)
     org.apache.tomcat.util.http.CookieSupport.isHttpToken(CookieSupport.java:229)
     org.apache.tomcat.util.http.ServerCookie.appendCookieValue(ServerCookie.java:185)
     org.apache.catalina.connector.Response.generateCookieString(Response.java:1054)
     org.apache.catalina.connector.Response.addCookie(Response.java:996)
     org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:380)
     admin.membersheep.hk.Controller.HomeController.Login(HomeController.java:327)
     sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     java.lang.reflect.Method.invoke(Method.java:498)
     org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220)
     org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
     org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
     org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
     org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
     org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
     org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
     org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
     org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
     org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
     org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
     org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
     org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 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

相关推荐