spring Boot要访问JSP需要添加二个架包支持
pom.xml
-
<dependency>
-
<groupId>org.springframework.boot</groupId>
-
<artifactId>spring-boot-starter-tomcat</artifactId>
-
<scope>provided</scope>
-
</dependency>
-
<dependency>
-
<groupId>org.apache.tomcat.embed</groupId>
-
<artifactId>tomcat-embed-jasper</artifactId>
-
<scope>provided</scope>
-
</dependency>
目录结构
![Spring Boot 初探之JSP Spring Boot 初探之JSP](/default/index/img?u=aHR0cHM6Ly9waWFuc2hlbi5jb20vaW1hZ2VzLzExMy82ODM1NjBlM2ZmMTQ0Yjg0MjllMzEzOTVmOTk1OWQxOS5wbmc=)
然后运行main方法直接访问,没有上下文路径
浏览器访问JSP
![Spring Boot 初探之JSP Spring Boot 初探之JSP](/default/index/img?u=aHR0cHM6Ly9waWFuc2hlbi5jb20vaW1hZ2VzLzkwNy9hZWNmMmNlYzA2NWQ3YTQ1MzBjMmRjMGVjZWM4OTQzMy5wbmc=)