利用IntelliJ IDEA快速搭建springboot的web系统,前端模板使用thymeleaf。在application.properties和l配置正确、静态资源加载目录无误情况下(hello.html位于templates下),成功启动DemoApplication.java后,在浏览器中访问localhost:8080/test/hello失败,出现Whitelabel Error Page页面、No mapping for GET/test/hello错误。
springboot 使用thymeleaf 动态页面跳转静态页面时,需要经过controller层才能实现跳转
添加一个controller,在里面加上hello.html的跳转映射@RequestMapping("/hello")
添加TestController.java
TestController.java
ller;import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;@Controller
@RequestMapping("/test")
public class TestController {@RequestMapping("/hello")public String hello() {return "hello";}
正确显示页面
springboot快速搭建web系统
springboot前端模板
springboot整合thymeleaf
springboot之默认首页(欢迎页)的设置
springboot+thymeleaf+layui登录注册demo
hello ! JJ ~
本文发布于:2024-01-29 12:51:52,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170650391415410.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |