package com.demo1.action;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.demo1.entity.Area;
import com.demo1.entity.City;
import com.demo1.service.PC;


/**
 * 
 * 
 * @author Zhang wenmeng qq 489382877
 * 
 * 
 */

@Controller
@RequestMapping("/")
public class PCAction {

	@Autowired
	PC service;// 调用业务层方法

	// 查询所有省位
	@RequestMapping("/showProvinceList")
	public String showProvinceList(HttpServletRequest request, HttpServletResponse response) {

		response.setContentType("text/html;charset=UTF-8");
		HttpSession session = request.getSession();
		session.setAttribute("proList", service.showProvinceList());// 存入作用域中
		return "/index.jsp";

	}

	// 根据ajax返回到控制器的省id来查询相对应的城市名
	@RequestMapping("/showCityListByPid")
	public void showCityListByPid(HttpServletRequest request, HttpServletResponse response, int pid) throws IOException {

		response.setContentType("text/html;charset=UTF-8");
		System.out.println(pid);// 打印前台ajax传来的省id
		List<City> city = service.showCityListByPid(pid);
		JSONArray json = JSONArray.fromObject(city);// 将集合转化为json格式
		response.getWriter().print(json.toString());
		response.getWriter().flush();
		response.getWriter().close();

	}

	// 根基ajax返回到控制器的城市id来查询相对应的区、县
	@RequestMapping("/showTownListByCid")
	public void showTownListByCid(HttpServletRequest request, HttpServletResponse response, int cid) throws IOException {
		response.setContentType("text/html;charset=UTF-8");
		System.out.println(cid);// 打印前台ajax传来的城市id
		List<Area> area = service.showAreaListBycid(cid);
		JSONArray json = JSONArray.fromObject(area);// 将集合转化为json格式
		response.getWriter().print(json.toString());
		response.getWriter().flush();
		response.getWriter().close();

	}
}
最近下载更多
mmmmmmppp  LV10 2022年12月12日
Rommel  LV27 2022年11月27日
t19611321  LV10 2022年6月21日
993365561  LV4 2021年12月9日
lsz000000  LV6 2021年4月9日
panbiao  LV11 2021年3月31日
RicardoLank  LV1 2021年2月6日
gytmtc  LV1 2020年7月31日
zui_2017  LV5 2020年6月27日
IT达人  LV22 2020年6月9日
最近浏览更多
shuangfu  LV24 2023年12月2日
limenghaoqwer  LV2 2023年11月27日
gecongkai  LV8 2023年6月22日
cunbie  LV4 2023年6月13日
yangbulx  LV3 2023年6月7日
微信网友_6509053506113536  LV1 2023年6月7日
小妹妹  LV7 2023年5月28日
189676630  LV4 2023年4月19日
mmmmmmppp  LV10 2022年12月12日
superding  LV5 2022年12月11日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友