Problem:
When SPRINGMVC uses the Redirectview or the "redirect:" prefix for redirection, Spring MVC finally calls:
Response.sendredirect (Response.encoderedirecturl (URL));
For some browsers, opening a new browser window, the first time you access the server, Encoderedirecturl () appends a section of Jsessionid to the URL,
If the initial URL is "http://www.sina.com.cn", the resulting URL is "http://www.sina.com.cn;jsessionid=126AFFB8D83764DB4843889A72C0E4B6 "
This is typically the way Java does things, and the server-side platform for other languages does not. This jsessionid often causes serious problems, for example, if you use the URL above with Jsessionid to access Sina's website directly, IE will report to you: the server could not be found.
Workaround:
do not redirect by spring MVC, call it yourself directly :
response.sendredirect (URL); return NULL // Tell spring MVC I've done the processing
Based on the need to expand the knowledge, if the problem has been resolved, the following can not be seen.
Other options:
1) also say by rewriting the Dofilter method:
/*** @ClassName: Corsfilter * @Description: (cross-domain filter)*/@Component Public classCorsfilterImplementsFilter {Private StaticLogger Logger = Loggerfactory.getlogger (corsfilter.class); @Override Public voidInit (filterconfig config)throwsservletexception {} @Override Public voidDoFilter (servletrequest req, Servletresponse resp, filterchain chain)throwsIOException, servletexception {httpservletresponse response=(HttpServletResponse) resp; Response.setheader ("Access-control-allow-origin", "*"); Response.setheader ("Access-control-allow-methods", "POST, GET, OPTIONS, DELETE, HEAD"); Response.setheader ("Access-control-max-age", "3600"); Response.setheader ("Access-control-allow-headers", "x-requested-with,content-type,accept"); Response.setheader ("P3P", "Cp=cao PSA our"); Httpservletresponsewrapper Wrappedresponse=NULL; if(reqinstanceofhttpservletrequest) {HttpServletRequest HttpRequest=(httpservletrequest) req; if(Httprequest.isrequestedsessionidfromurl ()) {Logger.info ("DoFilter Isrequestedsessionidfromurl"); HttpSession Session=httprequest.getsession (); if(Session! =NULL) {session.invalidate (); } //Wrap Response to remove URL encodingWrappedresponse =NewHttpservletresponsewrapper (response) {@Override Publicstring encoderedirecturl (string url) {logger.info ("DoFilter encoderedirecturl=" +URL); returnURL; } @Override Publicstring encoderedirecturl (string url) {logger.info ("DoFilter encoderedirecturl=" +URL); returnURL; } @Override Publicstring encodeurl (string url) {logger.info ("DoFilter encodeurl=" +URL); returnURL; } @Override Publicstring encodeurl (string url) {logger.info ("DoFilter encodeurl=" +URL); returnURL; } }; }} chain.dofilter (req, Wrappedresponse!=NULL?Wrappedresponse:resp); } @Override Public voiddestroy () {}
The core point is to
Response.sendredirect (Response.encoderedirecturl (URL)); instead: Response.sendredirect (URL);
after the test, it does not seem to solve the problem .
2) Cookie Spoofing
Encoderedirecturl () appends jsessionid to the URL only if it is not possible to determine whether the browser supports cookies, and if it can find a jsessionid cookie, it considers the browser to be cookie-enabled.
You can therefore create a jsessionid cookie yourself to deceive Encoderedirecturl ().
New Cookie ("Jsessionid", "xxxxxxxxxxxxxxxxxxxx"); Cookie.setmaxage (Integer.max_value); Response.addcookie (Cookie) , and then call the Spring MVC redirection feature to be no problem.
This method has not been tested.
404 problems and solutions caused by Jsessionid