【问题标题】:How to install dandelion datatables如何安装蒲公英数据表
【发布时间】:2015-09-22 12:37:43
【问题描述】:

我正在尝试安装蒲公英数据表,但配置有一些问题

按照指南 here 我在我的 pom 中添加了以下内容

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
</dependency>
<dependency>
    <groupId>com.github.dandelion</groupId>
    <artifactId>datatables-jsp</artifactId>
    <version>1.1.0</version>
</dependency>
<dependency>
    <groupId>com.github.dandelion</groupId>
    <artifactId>datatables-export-itext</artifactId>
    <version>1.1.0</version>
</dependency>

然后我将以下内容添加到我的 web.xml 文件中

<!-- Dandelion servlet definition and mapping -->
    <servlet>
        <servlet-name>dandelionServlet</servlet-name>
        <servlet-class>com.github.dandelion.core.web.DandelionServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dandelionServlet</servlet-name>
        <url-pattern>/dandelion-assets/*</url-pattern>
    </servlet-mapping>

<!-- Dandelion filter definition and mapping -->
    <filter>
        <filter-name>dandelionFilter</filter-name>
        <filter-class>com.github.dandelion.core.web.DandelionFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>dandelionFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

我将来自 spring mvc 控制器的数据提供给我的 jsp 页面,我在其中放置了以下内容

<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>

<datatables:table id="myTableId" data="${data}">
    <datatables:column title="ID" property="id" />
</datatables:table>

我正在使用 servlet 3.1(下面的 web.xml)

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

我的容器是 tomcat 8

问题

当表格已填充但无法访问 css 和 js 文件时。相反,数据表可以正常工作,但没有样式。但是分页有效。

下面生成的一些无法访问的链接。

http://localhost:8080/dtproject/dandelion/datatables/css/jquery.dataTables.css http://localhost:8080/dtproject/dandelion/jquery/js/jquery.js http://localhost:8080/dtproject/dandelion/datatables/js/jquery.dataTables.js

谁能帮忙?

谢谢

更新

为了告诉引擎从外部 CDN 加载资源,我在 datatables.properties 配置文件中添加了以下行

asset.locations.resolution.strategy = remote,webapp,webjar,classpath,jar

当我运行程序时出现此错误:

Dandelion: Some properties of your configuration file are not recognized.
The group 'asset' contains 1 unknown property:

【问题讨论】:

    标签: spring-mvc datatables servlet-3.0 dandelion


    【解决方案1】:

    我将 servlet 版本从 3.1 降级到 3.0,现在它可以工作了

    生活有时很奇怪

    【讨论】:

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