【问题标题】:Spring Error during execution of processor处理器执行期间出现弹簧错误
【发布时间】:2018-02-01 04:56:42
【问题描述】:

完整的错误是:

处理器执行期间出错 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (搜索:12)

当我有我的 search.html 页面时显示:

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <!--<meta charset="UTF-8">-->
    <title>Search Users</title>
</head>
<body>

<h3>Search Users</h3>
<form th:action="@{/user/search}" th:object="${searchCriteria}" method="post">
<p>First Name: <input type="text" value="*{firstname}"/></p>
<p>Last Name: <input type="text" value="${searchCritera.lastname}"/></p>
    <br/>
    <input type="submit" value="search"/>
</form>
</body>
</html>

但我随后将value 更改为th:field*{firstname}${searchCritera.lastname},如下所示:

<form th:action="@{/user/search}" th:object="${searchCriteria}" method="post">
<p>First Name: <input type="text" th:field="*{firstname}"/></p>
<p>Last Name: <input type="text" th:field="${searchCritera.lastname}"/></p>
    <br/>
    <input type="submit" value="Search"/>
</form>

现在我收到上面的错误,似乎无法修复它。我尝试了th:value,但它引发了另一个错误:

评估 SpringEL 表达式的异常:“searchCritera.lastname” (搜索:12)

【问题讨论】:

    标签: spring thymeleaf


    【解决方案1】:

    一般来说,当您使用美元符号时,请使用th:

    <input type="text" th:value="${searchCriteria.lastname}"/>
    

    并正确拼写变量名。

    还可以酌情包括name=th:field=(或者取而代之,具体取决于您要完成的工作)。

    【讨论】:

      猜你喜欢
      • 2012-07-03
      • 2017-02-05
      • 2012-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-02
      • 1970-01-01
      相关资源
      最近更新 更多