在templates下是动态页面,在static下是静态页面:
在static下的html页面可以通过端口号直接访问,如上图的hello静态页面访问http://localhost:8086/hello.html
templates下的只能是controller后的地址跳转
controlller有两种方式跳转到templates的页面
@GetMapping("/user/register")
public ModelAndView register(Model model) {
ModelAndView register = new ModelAndView("register");
return register;
}
@GetMapping("user/loginView")
public String loginGet(Model model) {
return "login";
}
那如何从动态跳转动态,动态跳转静态呢?
动态跳转动态,在templates下的register.html
<a th:href="@{/user/loginView}">登 录</a>
动态跳静态
<a href="/hello.html">跳转到静态hello.html</a> <!--此处跳转静态页面-->
静态跳动态
<a href="/user/loginView">静态跳动态</a> <!--此处跳转静态页面-->