一。省份不重複java
CommonSqlMap.xml中新寫一組,(用WHERE條件)web
<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>
相應的的ItemListComponent.java中數據庫
public List<Item> getProvinceList1() { return queryDao.executeForObjectList("Common.selectProvince1", null); }
相應的ExpressPriceControllor.java中express
List<Item> provinceList = itemListComponent.getProvinceList1(); model.addAttribute("provinceList", provinceList);
二。下拉表變單條顯示code
將省份的下拉列表去掉即下面的部分
orm
<form:select path="provinceId" itemValue="${expressPriceForm.provinceId}"> <form:options items="${provinceList}" itemLabel="label" itemValue="value" /> </form:select>
改成如下直接顯示(須叢數據庫中調用)xml
${expressPriceForm.provinceName}
ExpressPriceSqlMap.xml中調用province_name ,對selectExpressPriceList進行如下修改,從express_price, province兩個表中查找數據,需詳細區分下,即字段名前加上表名get
<select id="selectExpressPriceList" 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.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.province_id = province.province_id AND express_price.express_id = #expressId# </select>