请问下面两段代码一个用了重定向,另一个是直接return的,那么什么时候该用重定向,这两个地方有什么区别?
1 2 3 4 | @GetMapping ( "/" ) public String root() { return "redirect:/index" ; } |
1 2 3 4 5 6 | @GetMapping ( "/login-error" ) public String loginError(Model model){ model.addAttribute( "loginError" , true ); model.addAttribute( "errorMsg" , "登录失败,用户名或密码错误" ); return "login" ; } |
毕设 Elasticsearch搜索+Thymeleaf模板+JPA+Security+BootStrap
了解课程