2017-07-12 128 views
2

我使用的瓷磚與春天開機,並希望映射2 URL模式瓷磚春季啓動URL映射

前)

~~/something -> normal spring boot controller 
~~/something.tiles -> tiles pattern 

我檢查了各模塊工作正常,但idont知道如何地圖網址模式。

,當我用春天,我已配置的DispatcherServlet這樣

<servlet> 
    <servlet-name>Tiles Dispatch Servlet</servlet-name> 
    <servlet-class>org.apache.tiles.web.util.TilesDispatchServlet</servlet-class> 
</servlet> 
<servlet-mapping> 
    <servlet-name>Tiles Dispatch Servlet</servlet-name> 
    <url-pattern>*.tiles</url-pattern> 
</servlet-mapping> 

但我該如何配置它在春季啓動在web.xml中設置?

回答

1

您可以添加ServletRegistrationBean@Configuration

@Bean 
    public ServletRegistrationBean tilesServletRegistrationBean() { 
     return new ServletRegistrationBean(new TilesDispatchServlet(), "*.tiles"); 
    } 
+0

THX之一,@Bean註釋!它工作完美! –