标签:
一。省份不重复
CommonSqlMap.xml中新写一组,(用WHERE条件)
<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中
List<Item> provinceList = itemListComponent.getProvinceList1(); model.addAttribute("provinceList", provinceList);
二。下拉表变单条显示
将省份的下拉列表去掉即下面的部分
<form:select path="provinceId" itemValue="${expressPriceForm.provinceId}"> <form:options items="${provinceList}" itemLabel="label" itemValue="value" /> </form:select>
改为以下直接显示(须丛数据库中调用)
${expressPriceForm.provinceName}
ExpressPriceSqlMap.xml中调用province_name ,对selectExpressPriceList进行以下修改,从express_price, province两个表中查找数据,需详细区分下,即字段名前加上表名
<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>
标签:
原文地址:http://my.oschina.net/u/2411776/blog/485261