突然注意到网上好多查springboot跳转页面的,就想自己也记录下

首先是pom.xml里的依赖:就用原始的就好不添加东西,

springboot跳转页面

接下来是controller:

springboot的controller类上面要加上@Controller,方法里面要加上@RequestMapping注解,记住不要加responseBody不然会返回字符串。

springboot跳转页面

接下来看下页面,首先页面的位置要放对。我controller里配置的是html/index.html所以是放在项目里resources/static/html文件夹下的。

springboot跳转页面

springboot 这个文件夹默认文件名就是static不要修改啊。

页面的内容就看自己写了我的就是这样

springboot跳转页面

这样就可以了。看下我的结果

springboot跳转页面

 

 

相关文章: