Announcement Announcement Module
No announcement yet.
Spring MVC gives 404 for simple JSP request Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring MVC gives 404 for simple JSP request

    All I want to do is display a JSP. Why does everything in Spring have to be a chore?!
    Here is my app-servlet.xml config:

    <beans xmlns=""
        xmlns:mvc="" xmlns:xsi=""
        xmlns:aop="" xmlns:jee=""
        xmlns:lang="" xmlns:p=""
        xmlns:tx="" xmlns:util=""
        <!-- Enable @Controller annotation support -->
        <mvc:annotation-driven />
        <!-- Allow static resources to be served from the /resources folder -->
        <mvc:resources mapping="/r/**" location="/resources/" />
        <!-- Scan classpath for annotations (eg: @Service, @Repository etc) -->
        <context:component-scan base-package="com.cs" />
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix">
            <property name="suffix">
        <context:property-placeholder location="file:/TcatServer6/myapp/properties/myapp/" />
    You can see all my resources are in /resources under my /src/main/webapp dir for maven/eclipse. I mapped them to /r/...

    Removing the InternalViewResolver made no difference.
    Here's my web.xml

    <web-app xmlns=""
    I go to
    and get a 404 It is there. I can go to every content type such as html, js, css. Each has a folder under /resources. JSP is the only one that doesn't work. When I change the to '/*' for the myapp servlet mapping THEN it finds the JSP but doesn't precompile it! It just serves it up as like a text file.

    Also with spring, it seems to just ignore my index.html welcome page. Spring MVC, so far, has taken about 10x as long to do anything I could do in 5 minutes in J2EE.
    Please help me not hate spring MVC.

  • #2
    In your ViewResolver configuration, you set up JSP views to be prefixed with "/r/jsp" and suffixed with ".jsp".
    That's the part described here in the reference documentation (mapping view names to actual JSPs).

    The second part missing in your question is: what does your controller looks like? How did you map URLs to Controllers?
    This is described here in the reference documentation.

    Anyway this question is probably a better candidate for StackOverflow, perhaps with the "spring-mvc" and "jsp" tags.
    Could you post your question there?

    The forums are moving to stackoverflow, a page explaining all this will be available there in a few days:


    • #3
      No one there seems to know either. I am inches from abandoning Spring. It has been nothing but headaches. If I can't compile a simple JSP then what good is it. I've heard more people complain about these kinds of issues in Spring and returning to a simpler J2EE type approach to things.