Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as

报错信息

在我使用spring boot 项目通过thymeleaf进行页面跳转访问的时候,访问不了页面,显示如下报错

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Nov 02 19:59:17 CST 2023
There was an unexpected error (type=Not Found, status=404).

报错原因

此次错误是项目依赖版本不一致导致的,其他时候如果也有类似的报错可以看看相关依赖之间版本是否一致(特别是spring相关的版本和其他的依赖的版本)

解决办法

thymeleaf的版本不能太高,此3.0.x及以上版本无法和spring-boot的2.x.x版本对上,需要降低版本(或者用parent管控默认的版本)

报错例子

            
            










完整的pom.xml依赖


<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.0modelVersion>

    <groupId>org.examplegroupId>
    <artifactId>thymeleaf-testartifactId>
    <version>1.0-SNAPSHOTversion>
    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.6.6version>
        <relativePath/>
    parent>
    <dependencyManagement>
        <dependencies>
            
            










        dependencies>
    dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-thymeleafartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>
    dependencies>


project>

你可能感兴趣的:(springboot,java,spring,boot,thymeleaf)