Announcement Announcement Module
Collapse
No announcement yet.
url-mapping everything - can't find jsp view Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • url-mapping everything - can't find jsp view

    Hi,

    I want to url-map everything to my dispatch controller, so I have this in web.xml

    Code:
    <servlet-mapping>
    		<servlet-name>myservlet</servlet-name>
    		<url-pattern>/*</url-pattern>
    </servlet-mapping>
    However, I am using some basic MVC examples at the moment, using jsp as the view, using org.springframework.web.servlet.view.InternalResou rceViewResolver in my spring config.

    However, when I try to view a page, it executes the controller code but then can't find the jsp. I get a 404 error, and the message:
    NOT_FOUND RequestURI=/webapp/WEB-INF/jsp/main.jsp

    In the logs is:
    12796 [http-8080-Processor25] WARN org.springframework.web.servlet.PageNotFound
    - No mapping found for HTTP request with URI [/flist/WEB-INF/jsp/main.jsp] in
    DispatcherServlet with name 'myservlet'

    If I change the url mapping to specific patterns which match specific urls, I don't get this problem. So does that mean when the controller passes to the view, it is going through the dispatcher servlet a second time? Is there any way round this, I can't see how to map everything except jsp pages?

    Thanks
    Last edited by anorakgirl; Oct 17th, 2008, 02:44 PM.

  • #2
    We do static jsp's like this:

    Code:
    <bean id="contactUsController" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
            <property name="viewName" value="info.contactus"></property>
        </bean>
       <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <!-- Static views -->
                    <prop key="contactus.view">contactUsController</prop>               
                </props>
            </property>
        </bean>
    where info.contactus is a struts tile. You could do this with a jsp page then:

    http://localhost:8080/{yourcontext}/contactus.view

    will access that page (where {yourcontext} is the context your web app is deployed under).

    Comment


    • #3
      Hi,

      Thanks for the quick reply, and suggestion - its not a static jsp though, its the view used by a controller. I am using:

      Code:
      <bean id="viewResolver"
      		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      		<property name="viewClass"
      			value="org.springframework.web.servlet.view.JstlView"/>
      		<property name="prefix" value="/WEB-INF/jsp/"/>
      		<property name="suffix" value=".jsp"/>
      	</bean>
      my controller method returns a ModelAndView:
      Code:
      return new ModelAndView("main", "model", model);
      So the dispatcher servlet looks up the view 'main' and gets /WEB-INF/jsp/main.jsp. But then this seems to go through the dispatcher again because of my web.xml, and there is no mapping for it.

      Thanks

      Comment

      Working...
      X