1 回答

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超5個(gè)贊
1. 不通過Spring MVC做重定向,自己直接調(diào)用:
response.sendRedirect(url);
return null; //告訴Spring MVC我已經(jīng)完成了處理
2. 修改Spring MVC的代碼,將:
response.sendRedirect(response.encodeRedirectURL(url));
改為:
response.sendRedirect(url);
3. encodeRedirectURL()僅在無法確定瀏覽器是否支持cookie的時(shí)候才會(huì)在url后面附加上jsessionid,如果它能找到一個(gè)jsessionid的cookie,它就認(rèn)為瀏覽器是支持cookie的。因此可以自己創(chuàng)建一個(gè)jsessionid的cookie來欺騙encodeRedirectURL()。
Cookie cookie = new Cookie("jsessionid", "2jcligmgi6fh");
cookie.setMaxAge(Integer.MAX_VALUE);
response.addCookie(cookie);
然后再調(diào)用Spring MVC的重定向功能就沒有問題了:
return new ModelAndView("redirect:"+url);
添加回答
舉報(bào)