【发布时间】:2018-06-15 10:02:50
【问题描述】:
我有一个百里香叶形式和弹簧靴后端。我有一个模型类,它定义了它的 getter 和 setter 有点不同的名称。因此,当我要采用该模型并将其字段作为表单输入字段时,thymeleaf 无法将它们识别为字段。
这是我的模态,
public class scDto {
private Integer region;
private boolean isAmt;
public scDto() {
}
public Integer getRegion() {
return this.region;
}
public void setRegion(Integer region) {
this.region = region;
}
public boolean isAmt() {
return this.isAmt;
}
public void setAmt(boolean amt) {
this.isAmt = amt;
}
这是我的表单输入字段,
<input type="text" th:field="*{sc.isAmt}"/>
这是错误,
Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (price:331)
表单在区域字段中运行良好。但它不适用于 Amt 字段。 如果我将 isAmt() get 方法更改为 getIsAmt(),也许我可以解决这个问题。但是我无法更改模态类的任何方法名称,因为该类已经编译并且我通过 jar 文件使用它。有没有办法解决这个问题。
【问题讨论】:
-
我猜你可以尝试使用 {sc.amt} 来引用这个变量。有关 javabeans 表示法的更多信息,您可以在此处阅读:stackoverflow.com/a/17066599/7629196。
-
@Rulsan K. 谢谢它对我有用。你为什么不把它作为一个答案。
-
我刚刚做到了 =)
标签: java spring-boot thymeleaf