Whitelabel 错误页面而不是特定的 jsp 页面

我已经看到了几个关于这个问题的问题,但我还没有解决这个问题:


我已经检查过它们:


Springboot Whitelabel Error Page --- 我的控制器被spring找到并注册了。


Spring boot - Whitelabel 错误页面--- 我的控制器带有注释,@Controller并且我返回与我想查看的 jsp 文件名匹配的字符串。


这是我的pom.xml文件:


<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-parent</artifactId>

        <version>2.1.1.RELEASE</version>

        <relativePath /> <!-- lookup parent from repository -->

    </parent>

    <groupId>com.example</groupId>

    <artifactId>test</artifactId>

    <version>0.0.1-SNAPSHOT</version>

    <packaging>war</packaging>

    <name>demo</name>

    <description>Demo project for Spring Boot</description>

    <properties>

        <java.version>1.8</java.version>

    </properties>

    <dependencies>

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter</artifactId>

        </dependency>

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-web</artifactId>

        </dependency>

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-test</artifactId>

            <scope>test</scope>

        </dependency>

    </dependencies>

    <build>

        <plugins>

            <plugin>

                <groupId>org.springframework.boot</groupId>

                <artifactId>spring-boot-maven-plugin</artifactId>

            </plugin>

        </plugins>

    </build>

</project>

这是application.properties文件:


server.port=8088

spring.mvc.view.prefix=/WEB-INF/views/

spring.mvc.view.suffix=.jsp

这是文件夹结构:

http://img2.mukewang.com/622a064e0001fbaa02590594.jpg

Cats萌萌
浏览 148回答 1
1回答

繁花如伊

您需要在您的 pom 中添加以下依赖项&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.springframework.boot</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>spring-boot-starter-tomcat</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <scope>provided</scope>&nbsp; &nbsp; </dependency>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.apache.tomcat.embed</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>tomcat-embed-jasper</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <scope>provided</scope>&nbsp; &nbsp; </dependency>它应该工作。如需更多参考,您可以按照本教程进行操作https://github.com/spring-projects/spring-boot/tree/v2.1.1.RELEASE/spring-boot-samples/spring-boot-sample-web-jsp
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java