Whitelabel错误页面-应用程序没有针对/ error的显式映射

Shivam Aggarwal:

我已经配置了一个Spring Boot应用程序,但是在启动该应用程序时,出现以下映射错误

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

Mon Dec 24 12:46:27 IST 2018
There was an unexpected error (type=Not Found, status=404).
No message available

我通过以下链接更新了控制器,使其成为包含主类的根软件包的一部分。此应用程序没有针对/ error的显式映射

我已经为我的应用程序使用了下面提到的配置/代码:

build.gradle

buildscript {
    ext {
        springBootVersion = '2.1.1.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.ticket'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    implementation('org.springframework.boot:spring-boot-starter-data-jpa')
    implementation('javax.servlet:jstl')
    implementation('org.springframework.boot:spring-boot-starter-web')
    runtimeOnly('com.h2database:h2')
    testImplementation('org.springframework.boot:spring-boot-starter-test')
}

TicketController.java

package com.ticket.controller;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
public class TicketController {

    static Logger log = LogManager.getLogger();

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public ModelAndView homeScreen(ModelMap model) {
        return new ModelAndView("view");
    }   
}

application.properties

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

JSP路径

src/main/webapp/WEB-INF/jsp/view.jsp
Shivam Aggarwal:

默认情况下,Spring Boot不提供解析视图层Jsp的功能。在下面的属性中添加到

build.gradle

解决了这个问题

implementation('org.apache.tomcat.embed:tomcat-embed-jasper')

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

反复获取带有映射规范的WhiteLabel错误页面

此应用程序没有针对/ error的显式映射,因此您将其视为后备。-弹簧靴-jsp

Whitelabel Error Page此应用程序没有配置的错误视图,因此您将其视为后备

Spring Boot应用程序whitelabel错误页面

带有Angular + Springboot的Whitelabel错误页面

Whitelabel错误页面:带有Eclipse的Spring Boot应用程序

WhiteLabel错误页面,在sts控制台中没有错误消息

为什么在运行简单的Spring Boot应用程序时总是得到状态为“ 404”的Whitelabel错误页面

针对 Spring boot 应用程序中未映射的类错误

K => Ordered[K] 中没有可用的隐式视图。涉及默认参数的应用程序中发生错误

一些疑问与Spring MVC中的显式页面映射有关,究竟如何工作?

React JS - 应用程序没有填满整个页面

即使构建应用程序时没有错误,我的应用程序也会崩溃

我的iOS应用程序死机,但没有出现错误

春季启动应用程序关闭而没有错误

Dash应用程序不会绘图,但没有任何错误

我的应用程序死机,但没有出现错误

Android 应用程序崩溃,没有 logcat 错误

应用程序无法运行,但编译没有错误

应用程序无法打开,但没有错误..!

具有单页面应用程序刷新访问令牌的Oauth2隐式流

应用程序没有响应但没有错误 Discord.js

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

应用程序错误后,所有映射的驱动器共享将断开连接

由于有关堆栈映射框架的错误,因此无法运行我的JavaFX应用程序

应用程序信号 gem 在没有崩溃请求的情况下向应用程序信号发送错误

将简单的Web应用程序部署到Elastic Beanstalk时没有名为“应用程序”的模块错误

此应用程序没有明确的 /error 映射,因此您将其视为后备。在我新创建的 Spring boot 应用程序中

问题与Spring启动Web应用程序的部署:没有错误,但应用仍失败