Springboot项目是集成了tomcat,所以项目是打成jar包,通过SpringMVC注解的方式去运行,对于界面跳转,SpringBoot支持thymeleaf页面模板技术,也可以向普通java web项目一样使用jsp,下面就两种方式作说明:
1.使用thymeleaf模板技术
首先创建一个springboot web项目,可以在https://start.spring.io/ 上直接创建,添加spring web 组件,生成项目后导入到eclipse中即可,在pom文件中添加thymeleaf依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
然后在application.properties文件中配置
spring.thymeleaf.prefix=classpath:/templates/
项目的页面文件放置在/src/main/resources下的templates文件夹下。例如在templates下创建index.html文件: