SpringBoot学习(七)–整合JSP技术
SprinBoot是不推荐使用jsp的。
其中:spring-boot-starter-web是不包含jstl和tomcat-embed-jasper的 所以我们需要另外添加。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 使用jsp开发需要用到以下两个依赖-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
1:创建SpringBoot的全局配置文件:applicatioin.properties
#项目访问jsp项目的前缀
spring.mvc.view.prefix=/WEB-INF/jsp/
#项目访问jsp项目的后缀
spring.mvc.view.suffix=.jsp
创建Controller:
SpringBoot–整合Freemarker
<!--整合Freemarker的依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
1:
springboot要求模板形式的视图层技术的文件必须要放到/resources目录下的一个为templates的目录下
其他都一样操作