创建Spring Boot项目
实现热部署
添加pom.xml中的架包
1) 添加servlet依赖
<!-- servlet 依赖. -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
2) 添加jstl依赖
<!-- jstl支持 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
3) 添加tomcat支持
<!-- tomcat 的支持.-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope><--如果打包是jar,想要访问jsp的时候,请不要加上这个-->
</dependency>
当使用idea创建的springboot项目并且添加了web模块的只需要添加jstl和jasper包即可
<!-- jstl支持 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope> <--如果打包是jar,想要访问jsp的时候,请不要加上这个-->
</dependency>
修改配置文件
修改application.properties文件,添加配置
spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp
编写代码
Controller的spring注解不能是restController
注意
针对el表达式,类似${hello}这个对于servlet的版本是有限制的,2.4版本版本以下是不支持的,是无法进行识别的,请注意