我有一个基本表,其中一些值由 thymeleaf 通过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
这似乎与此处列出的几乎相同的问题:解析百里香模板时出错,但我希望有比“不使用 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>