2. 本身整个文件 16M>10M无法全部上传,所以学会抽出对自己有用的部分
MarketAction.java
package com.action; import java.util.Date; import java.util.List; import java.util.Map; import com.entity.Market; import com.biz.MarketBiz; import com.entity.Province; import com.biz.ProvinceBiz; import java.util.ArrayList; import java.io.UnsupportedEncodingException; import net.sf.json.JSONArray; import net.sf.json.JsonConfig; /** * ******************************************************** * @ClassName: MarketAction * @Description: 市级表 * @author 生成Action类 * @date 2014-08-28 下午 09:32:26 ******************************************************* */ public class MarketAction { private MarketBiz marketbiz; private Market market = new Market(); private Listmarketlist = new ArrayList (); private List provincelist = new ArrayList (); private JSONArray jsons; private Integer id; /** * *添加表 信息 * **/ public String addMarket(){ Integer results = marketbiz.addMarket(market); if (results > 0 ) { return "successs"; }else { return "error"; } } /** * *查询表 所有信息 * **/ public String getAllMarket(){ marketlist = marketbiz.getAllMarket(); if (marketlist.size() > 0 ) { return "success"; }else { return "error"; } } /** * *根据@id查询表 信息 * **/ public String getMarket_id(){ market.setProvince_id(id); marketlist = marketbiz.getMarket_id(market); if (marketlist.size() > 0 ) { JsonConfig config = new JsonConfig(); config.setExcludes(new String[]{"county"}); jsons = JSONArray.fromObject(marketlist,config); return "edit"; }else { return "error"; } } /** * *根据@id修改表 信息 * **/ public String updaMarket_id(){ try { marketbiz.updaMarket_id(market); } catch (Exception e) { // TODO: handle exception return "error"; } return "successs"; } /** * *根据@id删除表 信息 * **/ public String deleMarket(){ try { marketbiz.deleMarket(market); } catch (Exception e) { // TODO: handle exception return "error"; } return "successs"; } /** * *查询关联表 信息 * **/ public String reAllProvince(){ provincelist = marketbiz.reAllProvince(); if (provincelist.size() > 0 ) { return "relist"; }else { return "error"; } } public Market getMarket() { return market; } public void setMarket(Market market) { this.market = market; } public List getProvincelist() { return provincelist; } public void setProvincelist(List provincelist) { this.provincelist = provincelist; } public List getMarketlist() { return marketlist; } public void setMarketlist(List marketlist) { this.marketlist = marketlist; } public void setMarketbiz(MarketBiz marketbiz) { this.marketbiz = marketbiz; } public JSONArray getJsons() { return jsons; } public void setJsons(JSONArray jsons) { this.jsons = jsons; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } }
jilian.js
function changes(obj,selectid,url){ //当前对象,选中的id,url路径. var id = "#"+selectid; if($(obj).val() != 0){ $.ajax({type:"post",url:url,dataType:"json", data:{"id":$(obj).val()},//简写:TUDD. success:function(data){ $(id).html(""); $.each(data,function(i,item){ if(selectid == "shi"){ $(id).append(""); } if(selectid == "xian"){ $(id).append(""); } }); if(selectid == "shi"){ // 如果下一个是市,就加上请选择市. $(id).attr("disabled",false); $(id).append(""); $.each($("select"),function(i,item){ if(i >= $(id).index()){ i++; $("select:eq("+i+")").attr("disabled",true);//改变select不可用 $("select:eq("+i+")").val(0); } }) } if(selectid == "xian"){ //同上 $(id).attr("disabled",false); $(id).append(""); } } }); }else if(selectid == "shi" || selectid == "xian"){ //如果当前选择项是 请选择,那么下个就也是请选择, //且不可用- $.each($("select"),function(i,item){ if(i >= $(id).index()){ $(item).attr("disabled",true); $(item).val(0); } }) } }
页面部分:list.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="/struts-tags" prefix="s"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>县级表总览
市级id(外键) | 县级id | 县级名称 | 操作 |
添加 ">修改 )">删除 |
struts-contor.xml
Market/save.jsp Market/list.jsp marketgetAllMarket.action jsons Market/error.jsp MyJsp.jsp provincegetAllProvince.action Province/update.jsp Province/error.jsp County/save.jsp County/list.jsp countygetAllCounty.action jsons County/error.jsp
引用
Quote?