省份與前頁面的省份不重複java
1.addExpressPrice.jspweb
<div class="controls">express
<form:select path="provinceId">app
<form:options items="${provinceList}" itemLabel="label" itemValue="value" />jsp
</form:select>spa
</div>orm
2.ExpressPriceController.java
xml
@RequestMapping(value = "initAddExpressPrice", method = RequestMethod.GET)get
public String initAddExpressPrice(Model model, ExpressPriceForm expressPriceForm) {it
log.info("追加快遞商所屬價格初始化");
List<Item> provinceList = itemListComponent.getProvinceList1();
model.addAttribute("provinceList", provinceList);}
3.ItemListComponent.java
public List<Item> getProvinceList1() {
return queryDao.executeForObjectList("Common.selectProvince1", null);
}
4.CommonSqlMap.xml
<select id="selectProvince1"
resultClass="cn.agriculture.web.form.Item">
SELECT province_name as label,
province_id as value
FROM province
WHERE not exists(
SELECT express_price.province_id
FROM express_price
WHERE express_price.province_id =province.province_id )
</select>
點"編輯"單條顯示不能修改
在editExpressPrice.jsp把下拉列表形式修改成不可編輯
改前:
<td> <div class="controls">
<form:select path="provinceId">
<form:options items="${provinceList}" itemLabel="label" itemValue="value" />
</form:select>
</div></td>
改後:
<td>
<div class="controls">
${expressPriceForm.provinceName} ////只快遞的省份名稱,不可修改
</div>
</td>
在ExpressPriceSqlMap.xml修改,
<select id="selectExpressPrice"
parameterClass="cn.agriculture.web.form.ExpressPriceForm"
resultClass="cn.agriculture.web.form.ExpressPriceForm">
SELECT express_price.express_price_id as expressPriceId,
express_price.express_id as expressId,
province.province_name as provinceName,
express_price.province_id as provinceId,
express_price.separate_weight as separateWeight,
express_price.first_heavy_price as firstHeavyPrice,
express_price.continued_heavy_price as continuedHeavyPrice,
express_price.status as status,
express_price.note as note,
express_price.update_time as updateTime,
express_price.update_user as updateUser
FROM express_price,province
WHERE express_price.express_price_id = #expressPriceId#
AND express_price.province_id =province.province_id
</select>
註明:經過express_price快遞商價格表的全部字段名和province省份表的province_name來顯示,從express_price,province表中調用的條件是express_price表的express_price_id = #expressPriceId#字段,和 express_price表的province_id =province.province_id字段。