【发布时间】:2016-01-02 04:44:32
【问题描述】:
我是 Spring MVC 中的新手,在 ThymeLeaf 中绝对是新手。
所以我正在开发一个使用 TymeLeaf 作为视图技术的 Web 应用程序,我必须使用这个 Jquery Validation Plugin:http://jqueryvalidation.org/
所以我过去在 JSP 页面中使用过它。
如文档所示:http://jqueryvalidation.org/documentation/
我必须将 required 属性添加到必须由用户填写的输入标签中,如下所示:
<input id="cemail" type="email" name="email" required>
我尝试在我的 TymeLeaf HTML 页面中这样做:
<input id="nome" name="nome" type="text" th:value="*{nome}" required></input>
但问题是现在我在堆栈跟踪控制台中收到此错误消息并且页面未呈现:
15:36:47,180 ERROR [org.thymeleaf.templateparser.ErrorHandler] (http-localhost/127.0.0.1:8080-3) [THYMELEAF][http-localhost/127.0.0.1:8080-3] Fatal error during parsing: org.xml.sax.SAXParseException; lineNumber: 88; columnNumber: 78; Attribute name "required" associated with an element type "input" must be followed by the ' = ' character.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:175)
为什么?怎么了?如何正确地将 required HTML 属性设置为声明到 ThymeLeaf 页面中的输入标记?
【问题讨论】:
标签: html spring-mvc jakarta-ee model-view-controller thymeleaf