使用跳转静态页面的方法来跳转动态页面会出现 NOT FOUND 404
出于安全性的原因考虑,不能直接跳转
→
→→
→→→
写一个简单的例子来实现页面跳转(动态和静态)
在templates下新建页面,这里用house.html作为主页面
在static中建立静态页面index6.html
以下是代码 house.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>house</title>
<script type="text/javascript">
</script>
</head>
<body>
<h1>This is house.html</h1>
<a href="/html/index6.html">跳转6</a> <!--此处跳转静态页面-->
<br>
<a th:href="@{/showtitle}">跳转5</a> <!--此处跳转动态页面-->
</body>
</html>
controller
@RequestMapping("showtitle")
public String gotoIndex(){
return "index5";
}
springboot会自动去controller中找到showtitle请求,执行其中的内容
→跳转5
动态页面的跳转需要先请求服务器,访问后台应用程序,然后再转到页面,在springboot中不建议用jsp,用Thymeleaf来做动态页面。