SpringRedirectURL显示在浏览器的网络选项卡中,而不是浏览器本身

5jvtdoz2  于 2021-07-23  发布在  Java
关注(0)|答案(0)|浏览(173)

我有一个登录控制器,可以对用户进行身份验证并将其重定向到主页。我面临的问题是,不是重定向和显示网页的内容通常在浏览器上,请求“获取”主页只发生在后台。主页请求/响应显示在浏览器的“网络”选项卡中,而登录页本身根本不会更改。我怎样才能让spring将当前的登录页面更改为主页,而不是仅仅向主页发出请求,而根本不重定向用户?
两个控制器(主页和登录页)的代码如下:
登录控制器

@ApiOperation(value = "Log in a user using their username and password")
@RequestMapping(path = "/api/login", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ModelAndView login(HttpServletRequest req, LoginForm loginForm) {
    // Authentication Logic
    return new ModelAndView("redirect:/ui/home");
}

主页

@RequestMapping(value = "/ui/home")
public ModelAndView index() {
    return getModelAndView("index.html");
}

如何更改此行为,使主页实际加载到浏览器上?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题