SpringBoot 刨坑记(一)th:href页面跳转失败
2018-12-10 16:49
375 查看
使用跳转静态页面的方法来跳转动态页面会出现 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来做动态页面。
相关文章推荐
- spring boot security 登录失败跳转页面提示错误信息
- springboot跳转html页面
- spring boot security 实现登陆时ajax请求返回json,而不是直接页面跳转
- eclipse搭建简单springboot-mybatis项目实现页面简单跳转
- 关于springboot没有跳转到页面
- 使用SpringBoot的关于页面跳转的问题
- Spring boot 跳转到jsp页面的实现方法
- spring-boot跳转页面
- Spring Boot 跳转到 JSP 页面
- SpringBoot页面表单请求失败,错误400的解决办法
- springboot 如何跳转jsp页面
- springboot实现登录超时跳转到别的页面
- springboot中出现无法跳转到前台JSP页面
- Spring boot 跳转到jsp页面
- spring boot使用thymeleaf跳转页面实例代码
- springboot-thymeleaf(html页面跳转)
- 解决在chrome浏览器使用js的window.location.href跳转页面失败的问题
- springboot跳转页面报错
- Spring-boot 设置首页跳转到Html页面
- SprintBoot学习笔记(2):SpringBoot跳转至页面