【问题标题】:tiles url mapping with spring boot使用 Spring Boot 进行平铺 url 映射
【发布时间】:2017-07-12 05:17:27
【问题描述】:

我正在使用带有 spring boot 的磁贴,并且想要映射 2 个 url 模式

例如)

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

我检查了每个模块都可以正常工作,但不知道如何映射 url 模式。

当我使用 Spring 时,我在 web.xml 中配置了 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>

但是如何在 Spring Boot 中配置呢?

【问题讨论】:

    标签: java spring spring-mvc spring-boot tiles


    【解决方案1】:

    您可以在 @Configuration 类之一中添加带有 @Bean 注释的 ServletRegistrationBean

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-21
      • 1970-01-01
      • 2015-06-20
      • 1970-01-01
      • 2016-09-26
      相关资源
      最近更新 更多