上一篇 <<<SpringBoot常用注解及外部jar包注入方式
下一篇 >>>SpringBoot全局异常捕获
js、css、图片等静态资源文件,在src/main/resources/目录下创建
页面渲染
后缀为*.ftl
<!-- 引入freeMarker的依赖包. -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
########################################################
application.properties中freemarker的配置
########################################################
spring.freemarker.allow-request-override=false
spring.freemarker.cache=true
spring.freemarker.check-template-location=true
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
#spring.freemarker.prefix=
#spring.freemarker.request-context-attribute=
#spring.freemarker.settings.*=
spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/templates/
#comma-separated list
#spring.freemarker.view-names= # whitelist of view names that can be resolved
<dependencies>
<!-- SpringBoot web 核心组件 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<!-- SpringBoot 外部tomcat支持 -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
</dependencies>
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
tips:
a、创建SpringBoot整合JSP,一定要为war类型,否则会找不到页面.
b、不要把JSP页面存放在resources/jsp 不能被访问到,要存放到src/main/webapp目录下,然后根据spring.mvc.view.prefix配置创建目录
推荐阅读:
<<<SpringBoot核心设计理念和核心组件
<<<SpringBoot中有哪些starter
<<<如何自定义SpringBoot starter
<<<SpringBoot启动流程说明
<<<SpringBoot常用注解及外部jar包注入方式
<<<SpringBoot全局异常捕获
<<<SpringBoot整合各种持久层技术
<<<SpringBoot整合Mybatis分页插件
<<<SpringBoot使用Atomikos技术整合多数据源
<<<SpringBoot实现热部署
<<<SpringBoot性能调优
<<<SpringBoot的Actuator监控和Admin-UI可视化
<<<SpringBoot常见面试问题