Results 1 to 2 of 2

Thread: Question about InternalResourceViewResolver and JSP

  1. #1
    Join Date
    Jul 2010
    Posts
    1

    Default Question about InternalResourceViewResolver and JSP

    Hi all, I am working in a legacy application that has the following mapping for the dispatcher servlet:

    <servlet>
    <servlet-name>dispatch</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup>0</load-on-startup>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:/spring-web.xml</param-value>
    </init-param>
    </servlet>

    <!-- Servlet Mappings -->

    <servlet-mapping>
    <servlet-name>dispatch</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>

    Currently our views are freemarker and I'm moving them to JSP, I'm wondering why I'm getting 404's when trying to resolve the JSP views? Is it because the JSP's are their own controllers and therefore I can't map /* to the dispatch servlet? Here is the config for the view resolver:

    <bean id="viewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlVi ew"/>
    <property name="prefix" value="/WEB-INF/jsp/"/>
    <property name="suffix" value=".jsp"/>
    </bean>

  2. #2
    Join Date
    Oct 2008
    Location
    Poland, Wrocław
    Posts
    432

    Thumbs up

    Hi

    <servlet-mapping>
    <servlet-name>dispatch</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>
    With the above you've just mapped all requests to be handled by DispatcherServlet - both *.jsp and e.g. images, styles, scripts, etc.

    Either use "old school" "*.html" or "*.do" or "*.action" mapping or more "trendy", "rest-style" "/app/*" or similar mapping.

    regards
    Grzegorz Grzybek

Tags for this Thread

Posting Permissions

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