我正在使用Spring.AjaxEventDecoration动态填充我的JSP上的下拉列表,但它因为无法绑定到原始模型而抛出错误。我一直在研究这个问题,我不认为这是可能的,但它看起来应该是这样的帖子..帮帮我一个人!
好我的控制器笨拙地看起来像这样,
@Controller
@RequestMapping(value = "/cis/crimeProperty/")
public class CrimePropertyController
{
@RequestMapping(value = "/manageView", method = RequestMethod.GET)
public ModelAndView managePropertyDetails(Long propertyId) throws DAOException
{
Map<String, Object> model = new HashMap<String, Object>();
CrimePropertyVO crimePropertyVO = new CrimePropertyVO();
model.put("crimePropertyVO", crimePropertyVO);
return new ModelAndView("cis.crime.property.edit", model);
}
@RequestMapping(value = "/changeItemList", method = RequestMethod.POST)
public ModelAndView retrieveItemList(String propertyClass)
{
Map<String, Object> model = new HashMap<String, Object>();
..call service to get list of items from class..
model.put("propertyItemList", propertyItemList);
return new ModelAndView("/cis/property/crime_property_item", model);
}
}
我正在使用图块,所以我的图块定义看起来像这样,
<definition name="cis.crime.property.edit" template="/WEB-INF/jsp/cis/property/manage_crime_property.jsp">
<put-attribute name="itemListFrag" value="/WEB-INF/jsp/cis/property/crime_property_item.jsp"/>
我的(manage_crime_property.jsp)JSP看起来像这样,
<form id= "changeList" action="${pageContext.request.contextPath}/smvc/cis/crimeProperty/changeItemList" method="post">
<select id="propertyClassChange" path="propertyClass">
<option value="" label="-Please Select-"/>
<option value="CLO" label="CLOTHING"/>
<option value="TOL" label="TOOLS"/>
</select>
</form
<form:form modelAttribute="crimePropertyVO" action="${pageContext.request.contextPath}/smvc/cis/crimeProperty/saveProperty" method="post">
<table class="genericOutlinedTable" style="width: 100%;">
<tr>
<td><b>Item</b></td>
<td>
<tiles:insertAttribute name="itemListFrag" flush="true" ignore="false"/>
</td>
</tr>
<tr>
<td><b>Make</b></td>
<td><form:input path="propertyMake" size="20" maxlength="20"/></td>
<td><b>Model</b></td>
<td><form:input path="propertyModel" size="15" maxlength="15"/></td>
</tr>
</form:form>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({ elementId: 'propertyClassChange', 事件:“平变化”, formId: '变更表', params:{fragments:'itemListFrag'} }));
My (crime_property_item.jsp) JSP fragment looks like this,
<span id="itemListFrag">
<form:select path="propertyItem">
<form:option value="" label="-Please Select-">
<c:forEach var="itemList" items="${propertyItemList}">
<form:option value="${itemList.propertyCode}" label="${itemList.propertyCode}" />
</c:forEach>
</form:select>
</span>
它的所有配置都正确,当我更改第一个下拉菜单时,它调用我的控制器changeItemList方法,该方法返回我的JSP frag和项目列表以构成选项,但是我收到服务器错误... BindingResult和bean名称属性的普通目标对象都不能作为请求属性 我已经尝试在我的frag中只有选项标签,但这不起作用我尝试使用spring:bind标签和正常选择,但无法使其工作。
非常感谢您提供任何帮助。