Spring MVC Thymeleaf:th:field在测试时出错

时间:2014-07-22 15:28:30

标签: java spring-mvc testing thymeleaf

我使用Spring MVC和Thymeleaf。我创建了一个Thymeleaf页面,它可以正常工作(在我的浏览器中)。现在我尝试使用Thymeleaf test library进行测试,但它在SpringInputGeneralFieldAttrProcessor处出错,它发生在他看到的第一个输入字段。问题出在th:field="*{username}"上(当我删除所有th:fields时,测试仍在继续)。

我做错了什么?

Thymeleafs测试文件:

%CONTEXT
user = new [...].User()

# ------------------------------------------
%INPUT 
<span layout:include="page :: content" th:remove="tag"></span>

%INPUT[page] (file:src/main/webapp/WEB-INF/spring/views/CreateNewUser.html)

# ------------------------------------------
%OUTPUT
<Some HTML />

表格的一部分:

<form action="#" 
    th:action="@{/spring/CreateNewUser}"
    th:object="${user}" method="post">

<input type="text" th:field="*{username}" />

<button type="submit" id="submit">Save</button>     

错误是:

  |  ERROR [TemplateEngine] [THYMELEAF][main] Exception processing template "C:\[..]\test-classes\thymeleaftest\CreateNewUser.thtest-001": Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (page:60)
[2014-07-21 09:51:21][RTJ8C0][main] [test:end][C:\[...]\target\test-classes\thymeleaftest\CreateNewUser.thtest-001][529208814][KO] Test FAILED: Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (page:60) Time: 529208814ns (529ms).
org.thymeleaf.exceptions.TemplateProcessingException: Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (page:60)

0 个答案:

没有答案