Springboot 页面显示
并非是那种传授并分享知识的,只想在个人博客上把自己学的东西记录下来。
上一篇写的是如何创建项目的,这一篇是将IDEA的HTML内容显示在浏览器上。因为一步步学过来,pom.xml中添加的依赖越来越多,已经分不清显示HTML只需要精简到哪些依赖,这里我随便找两个比较简短的pom.xml依赖,就不回去仔细测试哪些是多余的了。另外我后期博客中,包的形式大致是这样的
另外我想说明一下,其实src下的webapp和web.xml是完全没用到的,只是以前习惯把webapp目录创建出来,众看官可以忽略或者不创建webapp
以前用的SSM框架比较多,现在使用Springboot这种轻便的框架还真有点不习惯。
以前是各种插件,各种pom.xml,web.xml依赖
现在基本就只pom.xml,resources下的application.properties为主,甚至dao跟service都简化很多(目前也只是刚学不久,纯属个人愚见)
聊完这些多余的,我们接着进入正题
首先添加pom.xml依赖,上面说了,我只是随意找了个简短的,反正后面都会用到,也不分只要哪些依赖就能实现了
启动类:AppLication
以及controller跟index页面
不用在tomcat选择项目启动,直接选择启动类直接启动项目
输入localhost:8080/index,就能显示在浏览器上了
有源码才能更好的理解
目前源码放置在百度云盘,后期源码应该会转GItHub保存