说明
由于工作的需要,在学习springboot时,学习了jsp的使用,最近又涉及到springboot的文件上传方式。找资料学习后,在这里记录总结下springboot的单个和多个文件的上传和下载及jsp的使用。
正文
一、jsp的使用
通过Spring Initializr创建新的springboot项目,添加依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- tomcat-embed-jasper -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
添加依赖后,在application.properties中配置文件的前缀和后缀:
spring.mvc.view.prefix=/WEB-INF/view/
spring.mvc.view.suffix=.jsp
#关闭默认模板引擎
spring.thymeleaf.cache=false
spring.thymeleaf.enabled=false
启动类继承SpringB