Spring web mvc and url mapping

Back to an old problem that I haven’t resolved. I want to map everything to my Spring Controller. So I can have urls like mydomain.com/this and mydomain.com/that

So I put this in my web.xml


I’m using the Spring Dispatcher Servlet, with jsp as the view, using
org.springframework.web.servlet.view.InternalResourceViewResolver in my spring config.  But it can’t find the view. I get:

NOT_FOUND RequestURI=/webapp/WEB-INF/jsp/main.jsp

In the logs is:
WARN org.springframework.web.servlet.PageNotFound
– No mapping found for HTTP request with URI [/webapp/WEB-INF/jsp/main.jsp] in
DispatcherServlet with name ‘myservlet’

So the request for the view is going through the Dispatcher Servlet too. Not sure how to get around this! This blog is turning into a list of problems, rather than solutions…

11 thoughts on “Spring web mvc and url mapping

  1. Hello anorakgirl,
    did you find any solution ?

    I had the same problem and resolved it by using :


    instead of :


    What upsets me is that for now I have no explanation why it works.

  2. Oop, sorry, had xml tags in my previous message. I meant using “/” in the servlet mapping, instead of “/*”. It solve the problem but I don’t fully understand why.

  3. I had the same problem trying to render JSP views. I removed the “*.jsp” servlet mapping from web.xml and it worked. Looks like spring is handing over the rendering to tomcat and tomcat is handing it straight back to spring.

  4. In my case I think the message is referring to a JSP which spring has asked tomcat to render. Tomcat checks it’s web.xml file to see what to do with it and due to some ambiguity in the URL mappings decides to sent it back to the spring despatcher/application servlet. You need to find a way of ensuring that Tomcat can tell that your JSPs are not to be sent back. Using a sub folder for example, which doesn’t match any of your patterns in web.xml. I’m assuming there is some special case handling for the mapping “/” to solve this but it is a bit confusing.

  5. I have this same problem. I am new to an existing project. When I added a new Controller and subsequent jsp file, I ran into this issue. The other pages work fine, but my new addition comes up page not found. I have checked the code many times, and it looks like I’m conforming to all the same conventions as the rest of the code. I attempted your proposed solution to this problem and all the other pages break… and still, my new page comes up with page not found. Is there something else that can cause this issue?

  6. Since this is two months old you may have figured this out by now…
    If not (or for others who find this page), here’s the gist of what’s going on…
    By mapping /*, the dispatcher servlet handles ALL requests
    Views that are built off InternalResourceView (like JstlView) do an internal forward to return the rendered view
    The internal forward comes right back to the dispatcher servlet
    Which hands the request to a controller (only now the request is probably something like /WEB-INF/view/my.jsp)
    The controller doesn’t know how to handle it

    Here is a pretty thorough overview of possible solutions…

  7. Hi all… Thanks for the “/” instead of “/*” worked…. I was trying to figure out this problem for more than an hour and finally read the post above and it really worked….. Thanks to the folks for posting this…

Leave a Reply

Your email address will not be published. Required fields are marked *