以复杂对象为键的Thymleaf绑定图

时间:2019-08-02 09:36:04

标签: thymeleaf

使用Thymleaf,我正在尝试提交一个包含以复杂对象作为键的Map的表单,但出现此错误:

java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'path.to.object.MyObject': no matching editors or conversion strategy found

这是我的代码:

<tr th:each="item: ${MyForm.myMap}">
    <td th:text="${item.key.name}"></td>
    <td th:if="${item.key.technicalName} eq ${someValue} ">
        <input type="text" th:field="
            *{myMap[__${item.key}__]}" th:value="${item.value}">
    </td>
    <td th:if="${item.key.technicalName} ne ${someValue} " 
        th:text="${item.value}"></td>
</tr>

MyObject是一个简单的pojo:

public class MyObject {
    private String name;
    private String technicalName;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTechnicalName() {
        return technicalName;
    }

    public void setTechnicalName(String technicalName) {
        this.technicalName = technicalName;
    }
}

0 个答案:

没有答案