SpringBoot 整合 Freemark JSP Thymeleaf 等常用页面模板
作者:互联网
在springboot项目中,导入了哪些jar包,springboot就默认打开哪些功能。这就是springboot提倡的习惯大于配置的理念。
<!-- SpringBoot 集成FreeMarker模板 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency>
只要在 pom.xml 中配置上面的配置,springboot就为我们开启freemarker的支持。
<!-- 引用 JSP --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> <dependency> <groupId>org.apche.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency>
只要在pom.xml中配置上面的配置项,springboot就为我们开启 JSP 模板功能。同时要在 src/main 下面创建 webapp/WEB-INF/jsp 目录结构,如下图:
最后在 application.properties 文件中进行如下配置
spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp
到这里以 jsp为页面模板就完成了。
标签:springboot,spring,配置,boot,Freemark,Thymeleaf,jsp,模板,SpringBoot 来源: https://www.cnblogs.com/why2wmz99/p/10346232.html