0

I use Tiles 2 with Spring 3.05. I want to map jsp files to controller, e.g.

 <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>*.html</url-pattern>
        <url-pattern>*.jsp</url-pattern>
 </servlet-mapping>

When I do so, I get "[WARN] org.springframework.web.servlet.PageNotFound [No mapping found for HTTP request with URI [/WEB-INF/*.jsp]" for all tiles.

How can I exclude the tiles (from within WEB-INF) from servlet-mapping? or maybe I can explicitly map those files to tiles servlet?

  • why do you want to map jsp files to controller? Please also see http://stackoverflow.com/questions/2764636/how-can-i-map-a-spring-controller-to-a-url-with-jsp-extension – Ritesh Feb 04 '11 at 13:17
  • @rRitesh, thanks for the link. What I wanted to do was to map old jsp links to new site (that use spring mvc). My original problem was slightly different. I used spring filter to dispatch request (to old links) to controllers, but unfortunately the hibernate session was not passed and each time a new connection was created - which caused the connections from pool to run out. I solved it by proper configuration of cp30: and so I don't need to map jsps anymore. – Marcin Olek Feb 05 '11 at 19:15

2 Answers2

0

Instead of doing this in web.xml, you should probably configure it in your context file. The instructions are available in the spring docs.

Raghuram
  • 51,854
  • 11
  • 110
  • 122
0

May this sippet of my spring-context.xml helps you to build your configuration. It is based on the fact that there are two kind of tiles configuration files:

  • /WEB-INF/layouts/tiles-layouts.xml contains the tiles layout definitin
  • /WEB-INF/jsp/controllers/**/views.xml are several files that bind the view and jsp

    <bean id="viewResolver"
            class="org.springframework.web.servlet.view.UrlBasedViewResolver">
            <property name="requestContextAttribute" value="requestContext" />
            <property name="viewClass"
                    value="org.springframework.web.servlet.view.tiles2.TilesView" />
    </bean>
    
    <!-- Configure Apache Tiles for the view -->
    <bean id="tilesConfigurer"
            class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
            <property name="definitions">
                    <list>
                            <value>/WEB-INF/layouts/tiles-layouts.xml</value>
                            <value>/WEB-INF/jsp/controllers/**/views.xml</value>                           
                    </list>
            </property>
    </bean>
    

One of the /WEB-INF/jsp/controllers/**/views.xml files:

 <tiles-definitions>

    <!-- Pages -->
    <definition name="site/list" extends="standard-layout">
            <put-attribute name="title" value="List Sites" />
            <put-attribute name="body" value="/WEB-INF/jsp/controllers/site/list.jsp" />
    </definition>
    <definition name="site/show" extends="standard-breadcrumb-layout">
            <put-attribute name="title" value="Show Site" />
            <put-attribute name="breadcrumbNavigation" value="/WEB-INF/layouts/siteBreadcrumbNavigation.jsp" />
            <put-attribute name="body" value="/WEB-INF/jsp/controllers/site/show.jsp" />
    </definition>
    <definition name="site/create" extends="standard-layout">
            <put-attribute name="title" value="Create Site" />
            <put-attribute name="body" value="/WEB-INF/jsp/controllers/site/create.jsp" />
    </definition>
    <definition name="site/update" extends="standard-layout">
            <put-attribute name="title" value="Update Site" />
            <put-attribute name="body" value="/WEB-INF/jsp/controllers/site/update.jsp" />
    </definition>

 </tiles-definitions> 
Ralph
  • 118,862
  • 56
  • 287
  • 383