This application has no explicit mapping for error

0 votes

I used maven to follow the tutorial: https://spring.io/guides/gs/uploading-files/ step by step. All the codes that are used were copied from this tutorial.

The App runs, but I get the error:

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Tue Jun 30 17:24:02 CST 2015 There was an unexpected error (type=Not Found, status=404). No message available

Can someone help me with this issue?

Apr 29, 2022 in Other DevOps Questions by Kichu
• 19,040 points
20,437 views

1 answer to this question.

0 votes

One of the reason this error coccured is that you forgot the @RestController annotation on top of your controller class import, import org.springframework.web.bind.annotation.RestController;

Refer the simple example below:

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

@RestController
public class HelloController {
@RequestMapping("/")
    public String index() {
        return "Greetings from Spring Boot!";
    }

}

The other cause of this issue is that you might be missing the @Configuration annotation in the MvcConfig class which basically does the mapping for ViewControllers and setViewNames.

Content of the file :

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
**@Configuration**
public class MvcConfig implements WebMvcConfigurer{
   public void addViewControllers(ViewControllerRegistry registry)
   {
      registry.addViewController("/").setViewName("login");
      registry.addViewController("/login").setViewName("login");
      registry.addViewController("/dashboard").setViewName("dashboard");
   }
}

I hope this helps.

answered May 2, 2022 by narikkadan
• 63,600 points

Related Questions In Other DevOps Questions

0 votes
2 answers
0 votes
1 answer

How to use Powershell DSC for application installation?

Occasionally folks want to be able to ...READ MORE

answered Jul 16, 2018 in Other DevOps Questions by Kalgi
• 2,680 points
931 views
0 votes
1 answer
+1 vote
1 answer
0 votes
0 answers
0 votes
0 answers

resource : Invocation of init method failed

I am getting this error when I ...READ MORE

May 16, 2022 in Java by Kichu
• 19,040 points
3,350 views
0 votes
0 answers

UnsatisfiedDependencyException: Error creating bean with name

 I'm trying to create a Spring CRUD ...READ MORE

May 21, 2022 in Java by Kichu
• 19,040 points
52,455 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP