城市的联动
package cn.itcast.javaee.js.provincecity;import java.io.IOException;import java.util.LinkedHashSet;import java.util.Set;import com.opensymphony.xwork2.ActionSupport;/** * 控制器 * @author AdminTC */public class ProvinceCityAction extends ActionSupport{ private String province; public void setProvince(String province) { this.province = province; //System.out.println("注入" + province); } //根据省份查询城市 public String findCityByProvince() throws Exception { setCity = new LinkedHashSet(); if("湖南".equals(province)){ setCity.add("长沙"); setCity.add("株洲"); }else if("广东".equals(province)){ setCity.add("广州"); setCity.add("中山"); setCity.add("佛山"); } return SUCCESS; } private Set setCity; public Set getSetCity() { return setCity; }}
<%@ page language="java" pageEncoding="UTF-8"%>省份-城市,基于jQuery的AJAX二级联动