当前位置: 首页 > 知识库问答 >
问题:

当我使用th:field时,thymeleaf th:field返回错误

强宾白
2023-03-14
<input type="text" name="title" />
<input type="text" th:field="${title}"/> 

以下是错误:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Feb 07 23:03:56 BRST 2019
There was an unexpected error (type=Internal Server Error, status=500).
An error happened during template parsing (template: "class path resource [templates/books/form.html]")
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/books/form.html]")

共有1个答案

薛枫
2023-03-14

请参阅此处的Thymeleaf文档

当th:field与带有上下文变量的th:object配对时,它用于自动填充值。

如果希望动态呈现标记的名称,则应该使用th:name

Book book = new Book();
book.setTitle("Winnie the Pooh");

ModelAndView mv = new ModelAndView("book/form");
mv.addObject("book", book);
<form th:object="${book}">
    <input type="text" th:field="*{title}">
</form>
 类似资料:
  • 有什么办法能做到这一点吗? 谢谢!

  • 问题内容: 根据javadoc的File.listFiles方法 如果此抽象路径名不表示目录,或者发生I / O错误,则返回null。 我知道我正在使用目录,但是已经收到结果,因此必须出现I / O错误。我对错误是什么非常感兴趣。 返回这样的结果时如何检索错误消息/代码? 问题答案: 使用(在Java 7+中),您将获得适当的例外。

  • 通过HTTP POST to URL发出请求: 授权头OAuth参数在HTTP授权头中发送 字段值oauth_consumer_key应用程序的consumer key(40个字符)oauth_nonce以ASCII格式随机生成的字符串。具有相同nonce和时间戳组合的后续请求将被忽略。建议使用64位随机数。oauth_签名请求签名oauth_签名方法HMAC-SHA1〃或“明文oauth_时间戳

  • 问题内容: 民间, 我试图了解MomentJS API。在机器上获取当前时间的合适方法是什么? 与 试图解析他们的文档,并且不清楚使用什么。 http://momentjs.com/docs/#/query/is-a- moment/ 问题答案: 在这里,您要为CurrentDate分配一个momentjs实例: 这里只是一个字符串,是momentjs实例的默认格式的结果: 这里是自一月…以来的秒

  • 各位,我正在开发一个项目与LTE 4G模块,并有一个问题描述如下: 我编写了一个SIM卡应用程序(使用Java技术)并将其下载到SIM卡中。 下载小程序后,将SIM卡插入读卡器,然后我可以通过读卡器将APDU发送到小程序。小程序工作正常,它接受APDU并给出响应。 完成APDU测试后,我将SIM卡插入到LTE 4G模块中,通过uart发送AT CCHO="A0BB01020304050001"(A