• Register
Welcome to Kodlogs, programming questions and answer website.
+1 vote
347 views

How to resolve Spring Boot web application error "Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback."

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Thu Feb 09 01:53:26 CET 2017
There was an unexpected error (type=Not Found, status=404).
No message available
by (1.5k points)  
reshown by

4 Answers

0 votes
Lets assume  that point one conceivable issue would be that the beneath class wouldn't had been made

For HTML pages utilize the beneath class

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;

import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import org.springframework.web.servlet.view.InternalResourceViewResolver;

@Configuration

@EnableWebMvc

open class ApplicationWebMvcConfig expands WebMvcConfigurerAdapter{

@Override

open void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {

configurer.enable();

}

@Bean

open InternalResourceViewResolver viewResolver() {

InternalResourceViewResolver resolver = new InternalResourceViewResolver();

resolver.setPrefix("/WEB-INF/html/");

resolver.setSuffix(".html");

return resolver;

}

}

For JSP pages utilize the underneath class

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;

import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import org.springframework.web.servlet.view.InternalResourceViewResolver;

@Configuration

@EnableWebMvc

open class ApplicationWebMvcConfig expands WebMvcConfigurerAdapter{

@Override

open void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {

configurer.enable();

}

@Bean

open InternalResourceViewResolver viewResolver() {

InternalResourceViewResolver resolver = new InternalResourceViewResolver();

resolver.setPrefix("/WEB-INF/jsp/");

resolver.setSuffix(".jsp");

return resolver;

}

}
by (8.9k points)  
0 votes

It would appear that they now exclude the spring-boot-starter-web reliance, so include it physically.

dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf', version: '2.0.0.RELEASE'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.0.0.RELEASE'
}
by (8.9k points)  
0 votes
About special case: This application has no unequivocal mapping for/blunder, so you are considering this to be a fallback.

The area of the Application startup class is wrong. To put the Application class on the furthest side, that is, to incorporate all sub-bundles

Cause: Spring-boot will naturally stack all segments under the bundle of the startup class and its sub-bundles.

In the springboot design record: application.yml or application.properties about the arrangement of the view resolver:

At the point when the spring-boot-starter-paren form under the pom record is high:

spring.mvc.view.prefix/spring.mvc.view.suffix (springBoot made as a matter of course utilizes this mode)

At the point when the spring-boot-starter-paren form under the pom record is low:

spring.view.prefix/spring.view.suffix

Controller URL way composing issue

@RequestMapping("xxxxxxxxxxxxxx")

The genuine access way does not coordinate "xxx". [You can pass judgment on the accuracy of the way by yielding a sentence in the controller]

On the off chance that your task is springBoot, the best approach to bundle it is as war bundle, the arrival estimation of the controller is a string, you have to discover the parse into jsp page, you should focus on pom Whether the tomcat-implant jasper reliance is added to the record
by (8.9k points)  
0 votes
dependency reuired to solve issue:

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

    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
by (8.9k points)  
...