Results 1 to 2 of 2

Thread: web.xml url-mapping = *.jsp not working

  1. #1
    Join Date
    Oct 2004
    Posts
    11

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    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.
    Chris Harris
    Carlisle, UK

Similar Threads

  1. Multiple Hibernate Mapping Locations
    By james_a_woods in forum Data
    Replies: 8
    Last Post: Apr 14th, 2010, 11:42 AM
  2. URL mapping, why don't I get it?
    By cerebis in forum Web
    Replies: 6
    Last Post: Oct 10th, 2005, 04:31 PM
  3. Replies: 4
    Last Post: Oct 5th, 2005, 11:04 AM
  4. Initialization of Connection Provider fails
    By DEVRocker in forum Data
    Replies: 2
    Last Post: Aug 9th, 2005, 10:14 AM
  5. Replies: 13
    Last Post: Dec 7th, 2004, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •