使用springboot(2.3.5)内置tomcat无法返回视图的问题:
如果application.properties的路径确认没问题,也没有多空格(检查),就是pom中少东西了,按照如下配置即可。
- 导入以下包,最重要的是jasper,如果打包冲突,尝试去掉scope
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<!-- 内置tomcat对jsp的解析-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<!-- servlet 依赖包 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<!-- JSTL (JSP standard Tag Library) JSP 标准标签库 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
2. 在pom文件<build>添加如下过滤
<resources>
<resource>
<directory>src/main/webapp</directory>
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
重新编译后会发现在target中出现了jsp页面
问题解决.