嵌套Map属性的Spring BindStatus路径

时间:2014-04-01 22:43:49

标签: java spring jsp spring-mvc

我有一个像这样的模型对象:

class Model {

    SubModel submodel = new SubModel();

}

class SubModel {

    Map props = Maps.newHashmap();
}

并且在jsp中我想将它们绑定到像这样的输入:

<spring:bind path="submodel.props['key']">
....input...
....errors.....
</spring:bind>

我正在接受下一个例外:

Caused by: java.lang.IllegalArgumentException: Type must not be null
    at org.springframework.util.Assert.notNull(Assert.java:112)
    at org.springframework.core.convert.AbstractDescriptor.<init>(AbstractDescriptor.java:35)
    at org.springframework.core.convert.ClassDescriptor.<init>(ClassDescriptor.java:31)
    at org.springframework.core.convert.TypeDescriptor.<init>(TypeDescriptor.java:563)
    at org.springframework.core.convert.TypeDescriptor.valueOf(TypeDescriptor.java:125)
    at org.springframework.validation.AbstractPropertyBindingResult.findEditor(AbstractPropertyBindingResult.java:165)
    at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:125)

是否可以将BindStatus与嵌套地图一起使用? BTW,jstl有效,但我想要一种更清晰的方法来绑定值和错误。

1 个答案:

答案 0 :(得分:0)