如何安装蒲公英数据表

时间:2015-09-22 12:37:43

标签: spring-mvc datatables servlet-3.0 dandelion

我正在尝试安装蒲公英数据表,我在配置方面遇到了一些问题

按照指南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 conf文件

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:

1 个答案:

答案 0 :(得分:1)

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

有时生活很奇怪