Organizational Research By

Surprising Reserch Topic

spring servlet mapping url pattern working but cant display

spring servlet mapping url pattern working but cant display  using -'java,spring,jsp,spring-mvc,servlets'






<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
    <property name="mediaTypes">
            <entry key="atom" value="application/atom+xml" />
            <entry key="html" value="text/html" />
            <entry key="json" value="application/json" />
    <property name="viewResolvers">
            <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
                <property name="prefix" value="/WEB-INF/views/" />
                <property name="suffix" value=".jsp" />
    <property name="defaultViews">
            <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />


@RequestMapping ( "/" )
public class IndexController extends BaseController
    @RequestMapping ( "/" )
    public String index ( Model model ){
        return index2(model);

    @RequestMapping ( "/index" )
    public String index2 ( Model model ){
        return "index";

And exist index.jsp File

I guess that is very good working



And More strange


Controller work it!! but don't display browser

What's going on?

Please help me.

And Log

DispatcherServlet with name 'dispatcher' processing GET request for [/WEB-INF/views/index.jsp]

No mapping found for HTTP request with URI [/WEB-INF/views/index.jsp] in DispatcherServlet with name 'dispatcher'

asked Oct 13, 2015 by kinnari
0 votes

Related Hot Questions

1 Answer

0 votes

Servlet containers have rules for how they map and handle URI requests. These can be found in the Servlet Specification. It's also important to note that most Servlet containers have a Servlet to handle JSPs, mapped to *.jsp, which is an extension mapping. Tomcat has a JspServlet to do this.

You've mapped your DispatcherServlet to


which is a path mapping. Path mappings take precedence over extension mappings. So when you submit your view name

return "index";

Spring will use the ViewResolver


to resolve a path to use with a RequestDispatcher's forward method. That path will be /WEB-INF/views/index.jsp. Now the Servlet container will receive that path and attempt to find a Servlet to handle it. Since you have a Servlet mapped to /* it will use it, but your DispatcherServlet doesn't have a mapping for that path and therefore responds with a 404.

The simple solution is to change your mapping to /, which is the default handler if no other matches are found. In this case, when you submit your view and the container must find a mapped Servlet, it will find the JspServlet and use it.

answered Oct 13, 2015 by sumit_jaiswalmca