当蒲公英dataTables Dialect存在时,Thymeleaf模板表会中断

时间:2013-07-12 20:24:31

标签: spring spring-mvc thymeleaf dandelion

我有一个基本表,其中一些值由百里香通过th:text=标签提供。

在我们将dandelion.datatables.thymeleaf.dialect.DataTablesDialect添加为模板引擎的第二个方言之前,一切正常。

当dataTables方言存在时,我在th:text

的第一个实例中得到以下异常
 org.thymeleaf.exceptions.TemplateProcessingException: Error processing template: dialect prefix "th" is set as non-lenient but attribute "th:text" has not been removed during process

这似乎与此处列出的问题几乎相同:Error parsing thymeleaf template但我希望有一个比“不使用dataTablesDialect”更好的解决方案

由于

---------------更新------------------------------- ----------

我的Java配置:

@Bean
public ThymeleafViewResolver thymeleafViewResolver() {
    ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
    viewResolver.setTemplateEngine(templateEngine());
    viewResolver.setViewNames(new String[]{"template*"});
    viewResolver.setOrder(1);

    return viewResolver;
}

@Bean
public ServletContextTemplateResolver templateResolver() {
    ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();

    templateResolver.setPrefix("/WEB-INF/views/");
    templateResolver.setSuffix(".html");
    templateResolver.setTemplateMode("HTML5");
    templateResolver.setCacheable(false);

    return templateResolver;
}

@Bean
public SpringTemplateEngine templateEngine() {
    SpringTemplateEngine templateEngine = new SpringTemplateEngine();

    templateEngine.setTemplateResolver(templateResolver());
    templateEngine.addDialect(dataTablesDialect());

    return templateEngine;
}

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

@Bean
public ContentNegotiatingViewResolver contentNegotiatingViewResolver() {
    ContentNegotiatingViewResolver viewResolver = new ContentNegotiatingViewResolver();

    List<ViewResolver> viewResolvers = new ArrayList<ViewResolver>();
    viewResolvers.add(thymeleafViewResolver());
    viewResolver.setViewResolvers(viewResolvers);

    return viewResolver;
}

我的模板中有趣的部分:

<table id="reviewtable" >
  <tbody class="gridtable">
    <tr>
         <td >compare:</td>
        <td th:text="${row.sys1Val}">111</td>
        <td th:text="${row.sys2Val}">223</td>
    </tr>
 </tbody>
</table>

1 个答案:

答案 0 :(得分:1)

这是bug,将在Dandelion-Datatables 0.9.0中修复。

同时,有两种解决方案:

  • 的确,根本不要使用DatatablesDialect: - /
  • 或在同一页面上显示的所有表格中使用DatatablesDialect