一般来说 spring form 如下用:
<form:form id="inputForm" modelAttribute="product" action="${ctx}/product/add" method="POST"\>
<form:input path="name" id="name"/>
需要后端传一个 product bean,而提交的也是 product.name
现在我想要的页面 randominput.jsp 诸如
<form:form id="inputForm" action="${ctx}/randomthings/add" method="POST"\>
<form:input path="type" type="hidden" id="type"/>
<form:input path="applePrice" id="applePrice"/>
<form:input path="location" id="location"/>
location 和 applePrice 并不在同一个 bean 内
后台大致是
@RequestMapping(value = {"addVouchers"}, method = RequestMethod.GET)
public String addVouchers(Model model) {
String type = getType();
model.addAttribute("type",type);
return "modules/randominput";
}
这样做结果却是 java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
如何解决啊?