标签:
一、无重复记录添加
1、addExpressPrice.jsp(以列表形式显示省份列表)
<td> <div class="controls"> <form:select path="provinceId"> <form:options items="${provinceList}" itemLabel="label" itemValue="value" /> </form:select> </div> </td>
2、ExpressPriceController.java(初始化页面)
@RequestMapping(value = "initAddExpressPrice", method = RequestMethod.GET) public String initAddExpressPrice(Model model, ExpressPriceForm expressPriceForm) { log.info("追加快递商所属价格初始化"); List<Item> provinceList = itemListComponent.getProvinceList1(expressPriceForm.getExpressId()); model.addAttribute("provinceList", provinceList); model.addAttribute("expressPriceForm", expressPriceForm); return "manager/expressPrice/addExpressPrice"; }
3、ItemListComponent.java
public List<Item> getProvinceList1(String expressId) { return queryDao.executeForObjectList("Common.selectExpressPriceProvince", expressId); }
4、CommonSqlMap.xml
<select id="selectExpressPriceProvince" parameterClass="java.lang.String" 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,express WHERE express_price.province_id=province.province_id AND express.express_id=express_price.express_id AND express.express_id=#value#) </select>
二、省份以列表形式显示
1、addExpressPrice.jsp
<form:select path="provinceId"> <form:options items="${provinceList}" itemLabel="label" itemValue="value" /> </form:select>
2、ItemListComponent.java
public List<Item> getProvinceList() { return queryDao.executeForObjectList("Common.selectProvince", null); } public String getProvinceLabel(String provinceValue) { return queryDao.executeForObject("Common.selectProvinceLabel", provinceValue, String.class); }
3、CommonSqlMap.xml
<select id="selectProvince" resultClass="cn.agriculture.web.form.Item"> SELECT province_name as label,province_id as value FROM province </select> <select id="selectProvinceLabel" parameterClass="java.lang.String" resultClass="java.lang.String"> SELECT province_name as label FROM province WHERE province_id = #value# </select>
标签:
原文地址:http://my.oschina.net/u/2411782/blog/490746