A blink of an eye in March 2020, the new coronavirus outbreak, are sitting at home, home study of the day, look at the video did not practice knocking the code, ah ... lazy. It found that the effect is not good. Fully resumed the day came, the multi-Dodo, and more to write about, doing notes. From this started
Spring Boot integration Jsp
1, pom.xml dependency is introduced
This is mainly dependent on the introduction of three:
used in the preparation of the javax.servlet-API the servlet
JSTL is JSP Standard Tag Library
tomcat-embed-jasper:Although the built-in spring boot tomcat, but did not carry rely tomcat-embed-jasper's. jsp page requires regular access to add this dependent on the tomcat, or can not access ==
tomcat-embed-Jasper conflict when packaged jar and will be added here, soPackaged need to add words == provided, allowed only responsible for compiling and testing. But I am here to add jsp access error, found no reason, no solid added.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
2, application.yml arrangement
I store the path of jsp:
spring:
mvc:
view:
prefix: /WEB-INF/views/jsp/
suffix: .jsp
3, configuration jsp access path
Dependent may not be found in the introduction which create jsp files, this idea requires configuration
file -> project Structure ----> model
4, the test
@Controller
@RequestMapping(value = "hello")
public class HelloController {
@RequestMapping(value = "test", method = RequestMethod.GET)
public String testSay (){
System.out.println("Hello World");
return "index";
}
}
5, an error may occur
The reason: tomcat-embed-jasper-dependent version and other principles, failed
to address:Reintroducedrely
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>