问题
I want to use Spring-Tiles intergration. Here you can see how my app looks like.
So my question is: why Spring-MVC dispatcher Servlet can not resolve my Target page ???
回答1:
The problem is that you use <url-pattern>/*</url-pattern>
in servlet mapping, so all requests are processed by DispatcherServlet
, including request to *.jsp
tiles. The most versatile way to solve it (but to keep restful urls without prefixes) is to use a UrlRewriteFilter.
回答2:
I think you're missing a critical ViewResolver. I checked the post you mentioned in SpringSource but I didn't see the following ViewResolver:
org.springframework.web.servlet.view.tiles2.TilesViewResolver
Try adding that ViewResolver and see if that would help. I use Spring and Tiles as well. I just have to declare that and the TilesConfigurer.
Check out these references:
Add TilesViewResolver to enable fallback if tiles definition does not exist
TilesViewResolver
回答3:
It's a common issue using Spring and it's due to the fact that the view (jsp) goes through the DispatcherServlet.
Try to modify your web.xml using
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>
and then add to your urlrewrite.xml something like:
<urlrewrite default-match-type="wildcard">
<rule>
<from>/</from>
<to>/app/</to>
</rule>
<rule>
<from>/**</from>
<to>/app/$1</to>
</rule>
<outbound-rule>
<from>/app/**</from>
<to>/$1</to>
</outbound-rule>
I'm assuming you're using urlrewrite, if you're not import the jar and add the filter mapping in your web.xml such as:
<filter>
<filter-name>urlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>urlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
来源:https://stackoverflow.com/questions/2977446/tiles-2-and-no-mapping-found-for-http-request-with-uri-spring-mvc