首页 > 编程语言 > 详细

springboot 跳转页面

时间:2020-09-20 20:18:01      阅读:40      评论:0      收藏:0      [点我收藏+]

输入 127.0.0.1:8080/index 跳转到对应的页面

一开始参照博客的里的介绍(如图),但页面返回结果 是 test,后来发现 使用的是 @RestController ,换成@Controller,页面跳转正确

 

技术分享图片

 

正确的跳转到页面的方法:

1.application.properties 文件新增如下

1 # 定位模板的目录
2 spring.mvc.view.prefix=/
3 # 给返回的页面添加后缀名
4 spring.mvc.view.suffix=.html

技术分享图片

 

 

 

 

 

 2.增加html文件,test.html ,如图

技术分享图片

 

 

 

 

 

3.control 文件新增:

1 @Controller
2 class MyControllerPages{
3     @RequestMapping(value = "/index", method = RequestMethod.GET)
4     public String index() {
5         return "test";
6     }
7 }

技术分享图片

 

 

 

4.演示:

技术分享图片

 

 

 

 

ps:小鱼最近每月更新的随笔很少很少,活有点多,需要多留点时间学习ヾ(?°?°?)??

 

参考链接:

https://www.cnblogs.com/guo-xu/p/11203740.html

springboot 跳转页面

原文:https://www.cnblogs.com/whycai/p/13701082.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!