当前位置: 首页 > 知识库问答 >
问题:

Spring Boot-Whitelabel错误页面

鲜于岳
2023-03-14

我是新来的春靴。当我在端口8080上启动spring-boot应用程序时,我出现了一个错误。我得到白标签错误页面。

我在/src/main/resources/templates/中创建了一个非常简单的html页面。

下面是我的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>

    <groupId>org</groupId>
    <artifactId>MyBanQ</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>MyBanQ</name>
    <description>compta Project</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <!-- <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency> -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

下面是我的应用程序的控制器

public class BanqueController {

    @Autowired
    private IBanqueMetier banqueMetier;

    @RequestMapping("/operations")
    public String index()
    {
        return "comptes";
    }
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>MyBanQ</title>
</head>
<body>
    <h3>Test</h3>
</body>
</html>
@SpringBootApplication
public class MyBanQApplication implements CommandLineRunner {

    public static void main(String[] args) {
         SpringApplication.run(MyBanQApplication.class, args);
    }

}

共有1个答案

臧友樵
2023-03-14

将注释@controller添加到您的控制器类中,您的html文件名应该是“comptes”,正如您在索引函数中提到的那样。

 类似资料:
  • 问题内容: 我正在尝试删除白标签错误页面,所以我所做的是为“ / error”创建了一个控制器映射, 但是现在我得到了这个错误。 不知道我做错了什么。请指教。 编辑: 已经添加 到application.properties文件中,仍然出现相同的错误 问题答案: 你需要将代码更改为以下内容: 你的代码无法正常工作,因为当你未指定的实现时,Spring Boot会自动将其注册为。 要查看该事实,请导

  • 我正在处理一个Spring boot项目,我使用了JSP文件并提供了Whitelabel错误页面。有一个意外的错误(type=Not ville, status=404)。 我已经将JSP放在/src/main/webapp/pages/中,并且已经用应用程序属性给出了路径。 这有几个模块,主要组件不包括Spring Boot依赖性,它只包括所需的特定模块。从其他模块继承的代码已用于Spring

  • 我坚持使用这个简单的MVC示例。当我启动应用程序并转到localhost:8080时,我得到了“白标签错误页面”,甚至我在“src/main/资源/模板”中创建了“index.html”。我还在我的索引方法上添加了@Request estMap(“/”)。我找不到问题。 : : -在"src/main/资源/模板"下:

  • 我开发了带有jar包装的小型spring boot应用程序。应用程序用例是,用户将登录到应用程序,它将显示欢迎页面。下面是我的代码。 主类 登录控制器类 登录。jsp welcome.jsp application.properties xml 现在,当我通过eclipse执行这个应用程序时,它工作得很好。我使用在目标文件夹中创建的maven工具构建了一个jar应用程序。我已经使用命令行从目标文件

  • 当我尝试使用控制器来使用@Controller来显示jsp页面时,“Whitelabel Error Page此应用程序没有 /error的显式映射,因此您将此视为后备。”显示。 我已经考虑过问题是否与组件扫描有关,但是当我将@Controller更改为@RestController时,网页可能会显示我键入的字符串。 我想问一下为什么使用@Controller时无法扫描bean,以及如何修复问题。