0

Firstly I know that Spring MVC has good integration with Tiles. But my problem is as below:

I have configured my web.xml as

<servlet>
    <description>Spring Dispatcher Servlet</description>
    <servlet-name>Dispatcher</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

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

And my Dispatcher-servlet.xml is configured as below:

<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"> 
    <property name="definitions">
        <list>
            <value>
                /WEB-INF/tiles-defs/base-layout.xml
            </value>
            <value>
                /WEB-INF/tiles-defs/application-layout.xml
            </value>
        </list>
    </property> 
</bean>

<bean id="tilesViewResolver" 
            class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" 
            value="org.springframework.web.servlet.view.tiles2.TilesView" />
    <property name="order" value="1" />
</bean>

Please Note that Dispatcher servlet is mapped to handle all requests. I don't want to configure it in way, such that it can handle only specif requests, say for example *.hmtl or *.do or *.form because i want my URL to be neat, that's a requirement.

I have tiles definition as below

<tiles-definitions>

    <definition name="publicLayout" .
            template="/WEB-INF/tiles-layouts/publicLayout.jsp">
        <put-attribute name="title" value="Home Page" />
        <put-attribute name="body" value="" />
    </definition>

    <definition name="home" extends="publicLayout">
        <put-attribute name="body" value="/WEB-INF/jsp/home.jsp" />
    </definition>

</tiles-definitions>

Now when i make a HTTP request to say a URL "http://localhost:8080/myapp/home", a annotated controller mapped with request-mapping "/home" handles the request and finally returns a ModelAndView with view name "home".

Finally when dispatcher servlet tries to render the page it says

No mapping found for HTTP request with URI [/myapp/WEB-INF/tiles-layouts/publicLayout.jsp]

But when i change my dispatcher servlet mapping such that *.html, its working fine, which i don't want to do.

What can be done here.?? i think its a very common problem.

praveenkjvs
  • 931
  • 1
  • 6
  • 8

1 Answers1

2

To handle all requests except for requests for JSPs you need to use

<url-pattern>/</url-pattern>
axtavt
  • 239,438
  • 41
  • 511
  • 482