Announcement Announcement Module
Collapse
No announcement yet.
Question about InternalResourceViewResolver and JSP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment

    Working...
    X