Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在SpringMVC中,重定向仍然保留在同一页面中_Java_Spring_Spring Mvc - Fatal编程技术网

Java 在SpringMVC中,重定向仍然保留在同一页面中

Java 在SpringMVC中,重定向仍然保留在同一页面中,java,spring,spring-mvc,Java,Spring,Spring Mvc,我想重定向到我的主页,但这不起作用: @RequestMapping(value = "logout", method = RequestMethod.GET) public String logout(HttpSession session) { this.setSessionAccount(session, null); return this.getRedirect("/index"); } 我的当前页面是host/u/center。有一些响应记录: 你应该 return

我想重定向到我的主页,但这不起作用:

@RequestMapping(value = "logout", method = RequestMethod.GET)
public String logout(HttpSession session) {
    this.setSessionAccount(session, null);
    return this.getRedirect("/index");
}
我的当前页面是
host/u/center
。有一些响应记录:

你应该

return "redirect:/index" 
而不是调用控制器的另一个方法。

您应该

return "redirect:/index" 
而不是调用控制器的另一个方法。

我知道问题出在哪里。 我使用ajaxget请求。 所以我仍然停留在同一页。 不管怎样,谢谢你的回答。

我知道问题出在哪里。 我使用ajaxget请求。 所以我仍然停留在同一页。
不管怎样,请等待您的答案。

该方法只需返回“redirect:”+action;返回值等于“redirect:/index”,那么您应该发布关于您的问题的更多详细信息。我当前的页面是center),我想注销。因此,我通过get方法请求。在控制器中,我重定向到“/index”,但它仍然保留在u/center中。该方法只返回“redirect:+action;返回值等于“redirect:/index”,那么您应该发布关于您的问题的更多详细信息。我当前的页面是center),我想注销。因此,我通过get方法请求。在控制器中,我重定向到“/index”,但它仍然保留在u/center中。发布相关代码,即getRedirect(“”)如何方法?????发布相关代码,即getRedirect(“”)方法如何???????