Springboot official recommends using templates for front-end page presentation, but does not exclude the use of JSP in the project.
When using JSPs, you need to configure:
1. Packing Select a war package in a project created with Maven
If you do not have a selection, you can also modify it directly in the Pom.xml project information.
2. Adding dependencies in Pom.xml
In addition to Spring-boot-starter-parent, spring-boot-starter-web dependencies, you need to add the following 2 dependent packages
<!--The following 2 dependencies must be introduced using the JSP feature - <Dependency> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-starter-tomcat</Artifactid> </Dependency> <Dependency> <groupId>Org.apache.tomcat.embed</groupId> <Artifactid>Tomcat-embed-jasper</Artifactid> </Dependency>
2. Adding configuration file information
Add the following configuration in Application.properties:
#使用jsp时, the following 2 parameters must be configured spring.mvc.view.prefix=/web-inf/jsp/spring.mvc.view.suffix=.jsp
Springboot Integrated JSP