addCookie时中文出错
Cookie userCookie = new Cookie(ContextConfigure.USER_COOKIE_NAME,user.getLoginname());
userCookie.setMaxAge( 60 * 60 * 24 * 30 );
userCookie.setPath( "/ ");
.WSAY_DOMAIN );
passwordCookie.setPath( "/ ");
response.addCookie( userCookie );//userCookie中包含中文时怎么会出错误呢?
错误信息为:
<Request processing failed; nested exception is
java.lang.IllegalArgumentException: 天天天天天fffffg>
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is
java.lang.IllegalArgumentException: 天天天天天fffffg
Caused by:
java.lang.
IllegalArgumentException: 天天天天天fffffg
at org.apache.tomcat.util.http.ServerCookie.maybeQuote(ServerCookie.java:276)
at org.apache.tomcat.util.http.ServerCookie.appendCookieValue(ServerCookie.java:209)
at org.apache.coyote.tomcat5.CoyoteResponse.addCookie(CoyoteResponse.java:935)
at org.apache.coyote.tomcat5.CoyoteResponseFacade.addCookie(CoyoteResponseFacade.java:290)
at javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:57)
at net.wsay.core.utils.CookieUtil.saveCookie(CookieUtil.java:34)
at net.wsay.app.web.UserController.onSave(UserController.java:129)
at net.wsay.core.commons.BaseManageController.save(BaseManageController.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:434)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:372)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:806)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:736)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(Appl