【发布时间】:2023-03-23 05:35:02
【问题描述】:
我有以下pojo:
public class Foo {
@Size(min=0,max=10)
private String bar = null;
@Size(min=0,max=10)
private String baz = null;
.... getters and setters
}
和以下控制器:
@Controller
@RequestMapping(value = "/path", method = RequestMethod.POST)
public class Control {
public String handler(@Valid Foo foo1, BindingResult res_foo1, @Valid Foo foo2, BindingResult res_foo2){
//Business logic
}
}
和下面的形式sn-p:
<form action="/path">
<input name="foo1.bar" type="text" />
<input name="foo1.baz" type="text" />
<input name="foo2.bar" type="text" />
<input name="foo2.baz" type="text" />
</form>
提交表单时出现以下错误:
java.lang.IllegalArgumentException: argument type mismatch
如果对象不同并且 pojo 具有不同的属性,则可以正常工作。有没有办法让这个工作?
【问题讨论】:
标签: java spring spring-mvc