Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in Java by (47.6k points)

While working with Spring MVC it responds with a 404 error and reported: "No mapping found for HTTP request with URI[....] in DispatherServlet"?

1 Answer

0 votes
by (106k points)

All your request will be served by your standard Spring MVC application which will serve all requests through a DispatcherServlet that you've registered with your Servlet container. The DispatcherServlet looks at its ApplicationContext and, if available, the ApplicationContext registered with a ContextLoaderListener for special beans it needs to set up its request serving logic. These beans are described in the documentation.

Below is the code that explains the concept of DispatherServlet:-

public InternalResourceViewResolver resolver() {

    InternalResourceViewResolver vr = new InternalResourceViewResolver();

    vr.setPrefix("/WEB-INF/jsps/");

    vr.setSuffix(".jsp");

    return vr;

}

added tomcat-embed-jasper:

<dependency>

       <groupId>org.apache.tomcat.embed</groupId>

        <artifactId>tomcat-embed-jasper</artifactId>

       <scope>provided</scope>

</dependency>

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...