2016-04-29 84 views
1

在同一頁我想重定向到我的主頁,但是這不工作:重定向仍然在Spring MVC中

@RequestMapping(value = "logout", method = RequestMethod.GET) 
public String logout(HttpSession session) { 
    this.setSessionAccount(session, null); 
    return this.getRedirect("/index"); 
} 

我的當前頁面host/u/center。這裏也有一些響應記錄:

enter image description here

+0

如何發佈相關的代碼,這將是getRedirect(「」)方法??????? –

回答

0

你應該

return "redirect:/index" 

,而不是調用控制器的另一種方法。

+0

該方法只返回「重定向:」+動作;返回值等於「重定向:/索引」 – matcloud

+0

然後,你應該發佈更多關於你的問題的細節。 –

+0

我的當前頁面是http:// localhost:8080/weixin/u/center(用戶中心),我想註銷。所以,我通過get method.In請求http:// localhost:8080/weixin/u/logout。控制器我重定向到「/ index」,但它仍然保留在u/center中。 – matcloud

0

我知道是什麼問題。 我使用ajax get請求。 所以我仍然在同一頁面。無論如何,坦克爲你的答案。