• 大小: 18.54MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-08
  • 语言: 其他
  • 标签: ajax  二级联动  

资源简介

使用SpringMVC mybatis写二级、三级联动,包含数据库

资源截图

代码片段和文件信息

package com.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.WebRequest;

import com.entity.Area;
import com.entity.City;
import com.entity.Province;
import com.google.gson.Gson;
import com.service.AreaService;
import com.service.CityService;
import com.service.ProvinceService;

@Controller
public class ProvinceController {

@Autowired
private ProvinceService provinceservice;
@Autowired
private CityService cityservice;
@Autowired
private AreaService areaservice;

//显示所有部门
@RequestMapping(“/showPro.action“)
public String selAll(int saveWebRequest request){
List proList = provinceservice.selAll();
request.setAttribute(“proList“ proListWebRequest.SCOPE_SESSION);
if(save == 1){
return “two.jsp“;
}else{
return “three.jsp“;
}
}

//选择省份出来城市
@ResponseBody
@RequestMapping(value=“/selectCityById.action“produces = “text/html;charset=UTF-8“)
public String selectCityById(String proIdHttpServletRequest request){
List cityList = cityservice.selectCityById(Integer.valueOf(proId));
Gson gson = new Gson();
String json = gson.toJson(cityList);
return json;
}

//选择城市出来区县
@ResponseBody
@RequestMapping(value=“/selectAreaById.action“produces = “text/html;charset=UTF-8“)
public String selectAreaById(String cidHttpServletRequest request){
List areaList = areaservice.selectAreaById(Integer.valueOf(cid));
Gson gson = new Gson();
String json = gson.toJson(areaList);
return json;
}

public ProvinceService getProvinceservice() {
return provinceservice;
}

public void setProvinceservice(ProvinceService provinceservice) {
this.provinceservice = provinceservice;
}

public CityService getCityservice() {
return cityservice;
}

public void setCityservice(CityService cityservice) {
this.cityservice = cityservice;
}

public AreaService getAreaservice() {
return areaservice;
}

public void setAreaservice(AreaService areaservice) {
this.areaservice = areaservice;
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-05-25 14:45  二级、三级联动\
     目录           0  2017-05-25 14:42  二级、三级联动\ajax\
     文件         606  2017-05-25 10:34  二级、三级联动\ajax\.classpath
     目录           0  2017-05-25 14:42  二级、三级联动\ajax\.myeclipse\
     文件         285  2017-05-25 14:42  二级、三级联动\ajax\.mymetadata
     文件        1747  2017-05-25 10:40  二级、三级联动\ajax\.project
     目录           0  2017-05-25 14:42  二级、三级联动\ajax\.settings\
     文件         500  2017-05-25 10:31  二级、三级联动\ajax\.settings\.jsdtscope
     文件         104  2017-05-25 10:39  二级、三级联动\ajax\.settings\com.genuitec.eclipse.core.prefs
     文件        1009  2017-05-25 10:38  二级、三级联动\ajax\.settings\com.genuitec.eclipse.j2eedt.core.prefs
     文件         364  2017-05-25 10:31  二级、三级联动\ajax\.settings\org.eclipse.jdt.core.prefs
     文件         450  2017-05-25 10:38  二级、三级联动\ajax\.settings\org.eclipse.wst.common.component
     文件         252  2017-05-25 10:31  二级、三级联动\ajax\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2017-05-25 10:31  二级、三级联动\ajax\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2017-05-25 10:31  二级、三级联动\ajax\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2017-05-25 14:42  二级、三级联动\ajax\src\
     目录           0  2017-05-25 14:42  二级、三级联动\ajax\src\com\
     目录           0  2017-05-25 14:42  二级、三级联动\ajax\src\com\controller\
     文件        2457  2017-05-25 14:26  二级、三级联动\ajax\src\com\controller\ProvinceController.java
     目录           0  2017-05-25 14:42  二级、三级联动\ajax\src\com\entity\
     文件         446  2017-05-25 09:56  二级、三级联动\ajax\src\com\entity\Area.java
     文件         468  2017-05-25 13:52  二级、三级联动\ajax\src\com\entity\City.java
     文件         315  2017-05-25 09:55  二级、三级联动\ajax\src\com\entity\Province.java
     目录           0  2017-05-25 14:42  二级、三级联动\ajax\src\com\mapper\
     文件         187  2017-05-25 14:04  二级、三级联动\ajax\src\com\mapper\AreaMapper.java
     文件         365  2017-05-25 14:10  二级、三级联动\ajax\src\com\mapper\AreaMapper.xml
     文件         191  2017-05-25 13:25  二级、三级联动\ajax\src\com\mapper\CityMapper.java
     文件         373  2017-05-25 13:25  二级、三级联动\ajax\src\com\mapper\CityMapper.xml
     文件         177  2017-05-25 11:07  二级、三级联动\ajax\src\com\mapper\ProvinceMapper.java
     文件         505  2017-05-25 13:13  二级、三级联动\ajax\src\com\mapper\ProvinceMapper.xml
     目录           0  2017-05-25 14:42  二级、三级联动\ajax\src\com\service\
............此处省略115个文件信息

评论

共有 条评论