Announcement Announcement Module
Collapse
No announcement yet.
web.xml url-mapping = *.jsp not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • web.xml url-mapping = *.jsp not working

    Hi,

    Wondering if someone could advise...I'm new to Spring, and was wondering about a url-mapping of *.jsp

    I can't get this to work :cry:

    I'm using Spring 1.1 and Tomcat 5.0.28

    My web.xml has
    <servlet-mapping>
    <servlet-name>mainapp</servlet-name>
    <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>

    My mainapp-servlet.xml file has
    <bean id="mainappController" class="web.MainappController"/>

    <bean id="urlMapping" ...
    <property name="mappings">
    <props>
    <prop key="/stocks.jsp">mainappController</prop>
    </props>
    </property>
    </bean>

    <bean id="viewResolver"
    <property name="prefix">
    <value>/WEB-INF/jsp/</value>
    </property>
    <property name="suffix"><value>.jsp</value></property>
    </bean>

    and class web.MainappController
    public ModelAndView handleRequest(HttpServletRequest arg0,
    HttpServletResponse arg1) throws Exception {
    return new ModelAndView("stocks");
    }

    Thanks

  • #2
    I think your problem is that you are using the .jsp suffix both for your servlet mapping and for your views.
    So when your controller returns 'stocks' as a view, your view resolver resolves this to /WEB-INF/jsp/stocks.jsp, which in turn gets mapped back to your servlet.

    I think you need to change your servlet mapping to use a different suffix.

    Comment

    Working...
    X