• Ajax+json实现菜单动态级联


    1:jsp

    //级联ajax处理函数

     function areaChange(){
        var areano=document.all("areaNo").value;
        var url="${pageContext.request.contextPath}/infoAction.do?method=queryPeopleByPosition";
          $.post(url,{areaNo:areano,position:"200"},
            function(personList){ 
                  var personList=personList.personList; 
                  $("#businessManager").empty();//删除所有option选项
                  document.all("businessManager").options.add(new Option('-请选择-',''));
                  for(var p in personList){
                     document.all("businessManager").options.add(new Option(personList[p],personList[p]));
                  }               
            },"json");
        }

    <td>地区</td>
    <td>
           <html:select property="areaNo" style=" 80px" onchange="areaChange()">
                  <html:option value="">-请选择-</html:option>
                  <c:forEach items="${listArea }" var="i">
                   <html:option value="${i.nodeNo }">${i.nodeName }</html:option>
                  </c:forEach>
                 </html:select>
    </td>
    <td>业务经理</td>
    <td>
                 <html:select property="businessManager" styleId="businessManager" style=" 80px">
                  <html:option value="">-请选择-</html:option>
                  <c:forEach items="${teamList}" var="i">
                   <html:option value="${i.staffName }">${i.staffName }</html:option>
                  </c:forEach>
                 </html:select>
    </td>

    2、java处理方法

    //查询根据地区动态查询对应职级人员信息(动态级联使用)
     public ActionForward queryPeopleByPosition(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception{
      try {
       String areaNo=request.getParameter("areaNo");
       String position=request.getParameter("position");
       P2pStaffInfo queryParams = new StaffInfo();
          queryParams.setAreaNo(areaNo);// 地区
          queryParams.setPosition(position);//

          List<StaffInfo> personJavaList = infoLogic.queryStaffInfo(queryParams);

       JSONObject personList=new JSONObject();
       JSONObject person=new JSONObject();
       if (null!=personJavaList&&personJavaList.size()>0) {
        for (P2pStaffInfo po:personJavaList) {
         person.put(po.getStaffName(), po.getStaffName());
        }
       }
       personList.put("personList", person);
       response.setCharacterEncoding("gbk");
       PrintWriter pw=response.getWriter();
       pw.write(personList.toString());
       pw.flush();
       pw.close();
      } catch (Exception e) {
       log.error("根据职级动态级联地区查询出错!", e);
       e.printStackTrace();
      }
      return null;
     }

  • 相关阅读:
    Token验证(JWT)JwtUtil工具类 (2)
    iOS UIScrollView基本用法和代理方法
    iOS UIButton左文字右图片,上图片下文字
    iOS-源代码管理工具(SVN)
    iOS-源代码管理工具(Git)
    ios 状态栏statusBar的背景颜色
    iOS 开发中常用的排序(冒泡、选择、快速、插入、希尔、归并、基数)算法
    iOS开发设置View某个角为圆角
    [已解决]Xcode编译项目最后失败:Error: Jar file buglySymboliOS.jar was not found. Please copy the jar file into ~/bin folder
    TableView滚动、自动收起键盘
  • 原文地址:https://www.cnblogs.com/Defry/p/4650704.html
Copyright © 2020-2023  润新知