【问题标题】:DandelionServlet is not being invoked没有调用蒲公英Servlet
【发布时间】:2015-09-03 01:53:38
【问题描述】:

这是我的问题。我正在尝试在我的 Spring-boot Thymeleaf 应用程序上设置蒲公英数据表。我相信我已经正确连接了所有东西。我可以从日志中的 AssetCacheManger 获取 javascript 文件,并从 URL 手动调用 DandelionServlet,但它不会像 GitHub 上的示例那样自动调用。另请注意,我安装了 Spring Security。在发布之前,我禁用了安全性以确保这不是问题。

POM

<dependency> <groupId>com.github.dandelion</groupId> <artifactId>datatables-thymeleaf</artifactId> <version>0.10.0</version> </dependency>

JavaConfig

@Configuration
public class DandelionConfig
{
    @Bean
    public DandelionDialect dandelionDialect()
    {
        return new DandelionDialect();
    }

    @Bean
    public DataTablesDialect dataTablesDialect()
    {
         return new DataTablesDialect();
    }

    @Bean
    public FilterRegistrationBean dandelionFilterRegistrationBean()
    {
         FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
         DandelionFilter dandelionFilter = new DandelionFilter();
         filterRegistrationBean.setFilter(dandelionFilter);
         return filterRegistrationBean;
    }

    @Bean
    public ServletRegistrationBean dandelionServletRegistrationBean()
    {
         ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
         DandelionServlet dandelionServlet = new DandelionServlet();
         servletRegistrationBean.setServlet(dandelionServlet);
         servletRegistrationBean.addUrlMappings("/dandelion-assets/*");
         return servletRegistrationBean;
    }
 }

这里是不同于 GitHub 示例的日志部分。在 AssetMapper 上找不到委托的位置

2015-06-17 12:57:51,503 Application: LMI [http-apr-8080-exec-7] DEBUG com.github.dandelion.datatables.core.configuration.DatatablesConfigurator - Initializing the Javascript generator...
2015-06-17 12:57:51,508 Application: LMI [http-apr-8080-exec-7] WARN  com.github.dandelion.core.asset.AssetMapper - No location found for delegate on AssetStorageUnit [name=dandelion-datatables, version=0.10.0, type=js, dom=null, locations={delegate=dandelion-datatables.js}, attributes=null, attributesOnlyName=[]]
2015-06-17 12:57:51,513 Application: LMI [http-apr-8080-exec-7] DEBUG com.github.dandelion.core.asset.cache.AssetCacheManager - Retrieving asset with the key 591a4c961431b5fb3c6eedecfc5cca1b6ea5b09d/dandelion-datatables-0.10.0.js
2015-06-17 12:57:51,513 Application: LMI [http-apr-8080-exec-7] DEBUG com.github.dandelion.core.asset.cache.AssetCacheManager - Storing asset under the key 591a4c961431b5fb3c6eedecfc5cca1b6ea5b09d/dandelion-datatables-0.10.0.js
2015-06-17 12:57:51,518 Application: LMI [http-apr-8080-exec-7] WARN  com.github.dandelion.core.asset.AssetMapper - No location found for delegate on AssetStorageUnit [name=dandelion-datatables, version=0.10.0, type=js, dom=null, locations={delegate=dandelion-datatables.js}, attributes=null, attributesOnlyName=[]]
2015-06-17 12:57:51,518 Application: LMI [http-apr-8080-exec-7] DEBUG com.github.dandelion.core.asset.cache.AssetCacheManager - Retrieving asset with the key 591a4c961431b5fb3c6eedecfc5cca1b6ea5b09d/dandelion-datatables-0.10.0.js
2015-06-17 12:57:51,518 Application: LMI [http-apr-8080-exec-7] DEBUG com.github.dandelion.core.asset.cache.AssetCacheManager - Storing asset under the key 591a4c961431b5fb3c6eedecfc5cca1b6ea5b09d/dandelion-datatables-0.10.0.js

谢谢,

【问题讨论】:

    标签: spring-security spring-boot thymeleaf dandelion


    【解决方案1】:

    参考这个答案

    Spring Boot + Thymeleaf + Dandelion configuration not working


    你能改用这个配置

    @Configuration
    public class DandelionConfig {
    
        @Bean
        public DandelionDialect dandelionDialect() {
            return new DandelionDialect();
        }
    
        @Bean
        public DataTablesDialect dataTablesDialect(){
            return new DataTablesDialect();
        }
    
        @Bean
        public Filter dandelionFilter() {
            return new DandelionFilter();
        }
    
        @Bean
        public ServletRegistrationBean dandelionServletRegistrationBean() {
            return new ServletRegistrationBean(new DandelionServlet(), "/dandelion-assets/*");
        }
    }
    

    连同这些依赖项

    <dependency>
        <groupId>com.github.dandelion</groupId>
        <artifactId>datatables-thymeleaf</artifactId>
        <version>0.10.1</version>
    </dependency>
    <dependency>
        <groupId>com.github.dandelion</groupId>
        <artifactId>datatables-spring3</artifactId>
        <version>0.10.1</version>
    </dependency>
    

    【讨论】:

      【解决方案2】:

      我使用 Thymeleaf 和 Dandelion-datatables 创建了一个简单的 Spring Boot 应用程序。

      您可以在这里获取代码https://github.com/ohiocowboy/datatable-thymeleaf-spring-boot-starter

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-16
        • 2013-08-08
        • 2016-09-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多