我正在处理一个表单在春天,它抱怨表单中只有一个变量(以前用过它,不知道为什么它停止工作,我之前和之后都没有java代码更改)< / p>
我的对象:
public class Store {
private String implementation;
private String name;
private int replication;
private String view;
private List<String> remote;
private List<String> clusters;
private String cluster;
private String type;
// getters and setters
}
我的控制员:
@RequestMapping(value="/aaaaa", method=RequestMethod.GET)
public ModelAndView showForm() {
ModelAndView model = new ModelAndView();
model.addObject("implementations", implData);
model.addObject("store", new Store());
model.setViewName("nameOfView");
return model;
}
@RequestMapping(value = "/aaaaa", method = RequestMethod.POST)
public ModelAndView processAddition(@ModelAttribute("store") Store store) {
// some processing
}
我的JSP表单:
<form:form id="form" name="form" method="post" modelAttribute="store" action="/zzzzz">
<fieldset>
<div class="input select">
<label for="implementation" >Implementation<span class="small">Choose implementation</span></label>
<form:select name="implementation" path="implementation">
<form:option value="">Choose Implementation</form:option>
<c:forEach items="${implementations.keySet()}" var="impl">
<form:option value="${impl}"><c:out value="${impl}" /></form:option>
</c:forEach>
</form:select>
</div>
<div class="input select">
<form:select id="cluster" name="cluster" path="cluster">
<form:option value="">Choose Cluster</form:option>
<c:forEach items="${implementations.get('aaaa').getClusters().keySet()}" var="cl">
<form:option value="${cl}"><c:out value="${cl}" /></form:option>
</c:forEach>
</form:select>
<form:select id="type" name="type" path="type">
<form:option value="">Cluster Type</form:option>
<form:option value="new">New</form:option>
<form:option value="old">Old</form:option>
</form:select>
<div style="display: none;" id="remote">
<label>Remote Sites <span class="small">Available Remote Sites</span></label>
<form:checkbox path="remote" id="remote" name="remote" value="" />
<div id="append">
**I am appending the "form:checkbox for remote dynamically here using javascript and for spring not to complain I added a empty checkbox on top, still it complains**
</div>
</div>
<input style="margin-left: 150px; width: 125px; height: 30px;" class="button" type="submit" value="Add" />
<div class="spacer"></div>
</div>
</div>
</fieldset>
</form:form>
堆栈跟踪:
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'remote' available as request attribute
org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:194)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:160)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:147)
org.springframework.web.servlet.tags.form.AbstractCheckedElementTag.autogenerateId(AbstractCheckedElementTag.java:78)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:138)
org.springframework.web.servlet.tags.form.AbstractSingleCheckedElementTag.writeTagContent(AbstractSingleCheckedElementTag.java:82)
org.springframework.web.servlet.tags.form.CheckboxTag.writeTagContent(CheckboxTag.java:52)
org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
任何帮助?
由于
答案 0 :(得分:0)
您的请求/模型中没有“远程”对象。您需要添加它,但复选框列表也不起作用。