Java Spring MVC Thymeleaf:th:字段给出测试错误
我将Spring MVC与Thymeleaf一起使用。我创建了一个Thymeleaf页面,它可以正常工作(在我的浏览器中)。现在我尝试用测试它,但它在Java Spring MVC Thymeleaf:th:字段给出测试错误,java,spring-mvc,testing,thymeleaf,Java,Spring Mvc,Testing,Thymeleaf,我将Spring MVC与Thymeleaf一起使用。我创建了一个Thymeleaf页面,它可以正常工作(在我的浏览器中)。现在我尝试用测试它,但它在SpringInputGeneralFieldDattrProcessor中给出了一个错误,它发生在他看到的第一个输入字段。问题在于th:field=“*{username}”,(当我删除所有th:field时,测试将继续) 我做错了什么 AFS测试文件: %CONTEXT user = new [...].User() # ----------
SpringInputGeneralFieldDattrProcessor
中给出了一个错误,它发生在他看到的第一个输入字段。问题在于th:field=“*{username}”
,(当我删除所有th:field
时,测试将继续)
我做错了什么
AFS测试文件:
%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 />
您正在将一个
user
对象传递给th:object
,但您在上下文中将其定义为userObject
。我检查了它,但显然我在重写测试文件以使问题更清楚时犯了一个错误。无论如何谢谢你!
<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)