Tiles 2 And No mapping found for HTTP request with URI - Spring-MVC

后端 未结 3 993
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 00:07

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

相关标签:
3条回答
  • 2020-12-04 00:47

    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

    0 讨论(0)
  • 2020-12-04 01:04

    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> 
    
    0 讨论(0)
  • 2020-12-04 01:06

    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.

    0 讨论(0)
提交回复
热议问题