js控制筛选

来源:互联网 发布:看照片的软件 编辑:程序博客网 时间:2024/05/13 11:12

控制器Controller中对需要筛选的熟悉字段与Jsp页面进行交互,将条件字段放入map集合中

@RequestMapping("prodlist")    public String prodList(InsuranceProdForm insuranceProdForm, PageForm pageForm, Model model) {        Map<String, Object> params = new HashMap<String, Object>();        <span style="color:#FF0000;">params.put("paymentMethod", insuranceProdForm.getPaymentMethod());        params.put("type", insuranceProdForm.getType());</span>        Page<InsuranceProd> pageList = insuranceProdService.<span style="color:#FF0000;">getByParams</span>(params, pageForm.getFirstResult(), pageForm.getMaxResults());        model.addAttribute("pageList", pageList);       <span style="color:#FF0000;"> model.addAttribute("queryModel", insuranceProdForm);</span>        return "biz/insurance/prodlist";    }

Jsp页面

<script type="text/javascript">$(function(){$("a[name=type_dd]").click(function(){$("#type").val($(this).attr("val"));$("#PageForm1").submit();});$("a[name=paymentMethod_dd]").click(function(){$("#paymentMethod").val($(this).attr("val"));$("#<span style="color:#FF0000;">PageForm1</span>").submit();  // 此处名字必须是你的表单的id});});</script><form id="PageForm1" name="PageForm1" action="prodlist.htm" method="post">     <input type="hidden"  name="type"  id="type"  value="${queryModel.type}"/>     <input type="hidden"  name="paymentMethod"  id="paymentMethod"  value="${queryModel.paymentMethod}"/><div class="insucp">       <h3 class="product_ti">产品筛选</h3><div class="affairs_qy_p">险种:</div><a <c:if test="${empty queryModel.type}">  class="on" </c:if> val="" name="type_dd" >全部</a><a <c:if test="${'寿险' == queryModel.type}">  class="on" </c:if> val="寿险" name="type_dd">寿险</a><a <c:if test="${'年金险' == queryModel.type}">  class="on" </c:if> val="年金险" name="type_dd">年金险</a><a <c:if test="${'意外险' == queryModel.type}">  class="on" </c:if> val="意外险" name="type_dd">意外险</a><div class="affairs_qy_p">缴费方式:</div><a <c:if test="${empty queryModel.paymentMethod}">  class="on" </c:if> val="" name="paymentMethod_dd" >全部</a><a <c:if test="${'趸缴' == queryModel.paymentMethod}">  class="on" </c:if> val="趸缴" name="paymentMethod_dd" >趸缴</a><a <c:if test="${'期缴' == queryModel.paymentMethod}">  class="on" </c:if> val="期缴" name="paymentMethod_dd">期缴</a></form> 

xml数据库配置文件中的条件(PS:这次才知道原来xml文件中也可以存在EL表达式)

<select id="getByParams" parameterType="java.util.Map"  resultMap="BaseResultMap" resultType="ciis.zht.model.entity.InsuranceProd">        SELECT * FROM        ( SELECT A.*, ROWNUM RN  FROM        (SELECT * FROM T_M_INSURANCE_PROD TF        <where>            1=1            <if test="type!=null and type!='' ">AND TF.PROD_TYPE = #{type}</if>            <if test="paymentMethod!=null and paymentMethod!='' ">AND TF.PAYMENT_METHOD = #{paymentMethod}</if>        </where>        ORDER BY AUTO_ID DESC ) A        WHERE ROWNUM <=  #{lastResult} )        WHERE RN >= #{firstResult}    </select><pre name="code" class="html"><select id="getCountByParams" parameterType="java.util.Map"  resultType="long">        SELECT COUNT(AUTO_ID)        FROM T_M_INSURANCE_PROD TF        <where>            1=1            <if test="type!=null and type!='' ">AND TF.PROD_TYPE = #{type}</if>            <if test="paymentMethod!=null and paymentMethod!='' ">AND TF.PAYMENT_METHOD = #{paymentMethod}</if>        </where></select>

PS:Dao与ServiceImpl中的代码

public interface InsuranceProdDao extends ProductionDao<InsuranceProd> {       List<InsuranceProd> getByParams(Map paramMap);    Long getCountByParams(Map paramMap);}<pre name="code" class="html">@Overridepublic Page<InsuranceProd> getByParams(Map params, int firstResult, int maxResults) {    params.put("firstResult",firstResult);    params.put("lastResult",firstResult + maxResults - 1);    List<InsuranceProd> list = insuranceProdDao.getByParams(params);    long count = insuranceProdDao.getCountByParams(params);    return new Page<InsuranceProd>(list, count, firstResult, maxResults);}

 




0 0
原创粉丝点击