1、打开idea 进入创建项目的页面

快速搭建基于SpringBoot + thymeleaf的web项目

2、选择Spring Initializr

快速搭建基于SpringBoot + thymeleaf的web项目

3、填写当前界面的参数

快速搭建基于SpringBoot + thymeleaf的web项目

4、选择导入web与Thymeleaf 的jar包

快速搭建基于SpringBoot + thymeleaf的web项目

5、直接点击下一步

快速搭建基于SpringBoot + thymeleaf的web项目

6、mevan导入jar包

快速搭建基于SpringBoot + thymeleaf的web项目

7、创建几个文件

快速搭建基于SpringBoot + thymeleaf的web项目

      1)、创建controller包(控制层)

               1、创建与前端进行交互的WebController.java文件

                快速搭建基于SpringBoot + thymeleaf的web项目

               2、创建当页面跳转出错时的错误页面跳转

               快速搭建基于SpringBoot + thymeleaf的web项目

      2)、创建静态页面(html)

         ps:static包中放css,image,js,font等文件

                 templates包中放html等界面

              index.html:

              在html标签中定义当前html使用thymeleaf模板

              使用 th:text="${后端通过model传来的参数的key}"

              快速搭建基于SpringBoot + thymeleaf的web项目

              error界面:

              如上图,按照后端配置的跳转的路径进行创建即可(html页面)

8、测试

    启动:快速搭建基于SpringBoot + thymeleaf的web项目

浏览器中输入项目页面跳转地址:

快速搭建基于SpringBoot + thymeleaf的web项目

浏览器输入获取参数的地址:

快速搭建基于SpringBoot + thymeleaf的web项目

输入不存在的地址:

快速搭建基于SpringBoot + thymeleaf的web项目

至此springBoot项目优雅的创建成功,在其中加入了错误页面跳转的骚操作,其实这一步不要程序也可以正常运行起来的

相关文章: