jquery json ajax例子
配置文件
对应的actionpackage jp.co.syspro.action.ajax;import java.util.List;import jp.co.syspro.common.module.LabelValueBean;import jp.co.syspro.common.util.JsonUtil;import jp.co.syspro.service.ajax.AjaxService;import com.opensymphony.xwork2.ActionSupport;@SuppressWarnings("unchecked")public class AjaxAction extends ActionSupport {private static final long serialVersionUID = -5057041300197154859L;private AjaxService ajaxService = null;/** * エリア */private String area;/** * 区 */private String district;/** * 都道府 */private String prefecture;/** * 市町村 */private String adArea;private List<LabelValueBean> optionList = null;/** * 全てエリア取得 * * @return エリアリスト * @throws Exception */public String getAllArea() throws Exception {optionList = ajaxService.getArea();JsonUtil.sendJson(optionList);return null;}/** * エリアによる 区取得 * * @return 区リスト * @throws Exception */public String getDistrictByAreaCd() throws Exception {optionList = ajaxService.getDistrictByAreaCd(area);JsonUtil.sendJson(optionList);return null;}/** * 区によって 店取得 * * @return 店リスト * @throws Exception */public String getTenpoByDistrictCd() throws Exception {optionList = ajaxService.getTenpoByDistrictCd(district);JsonUtil.sendJson(optionList);return null;}/** * 全てadエリア取得 * * @return adエリアリスト * @throws Exception */public String getAdArea() throws Exception {optionList = ajaxService.getAdArea();JsonUtil.sendJson(optionList);return null;}/** * adエリアによる 都道府取得 * * @return 都道府スト * @throws Exception */public String getPrefectureByAreaCd() throws Exception {optionList = ajaxService.getPrefectureByAreaCd(adArea);JsonUtil.sendJson(optionList);return null;}/** * 都道府によって 市町村取得 * * @return 市町村リスト * @throws Exception */public String getCityByPrefectureCd() throws Exception {optionList = ajaxService.getCityByPrefectureCd(prefecture);JsonUtil.sendJson(optionList);return null;}public String getDistrict() {return district;}public void setDistrict(String district) {this.district = district;}public void setArea(String area) {this.area = area;}public String getArea() {return area;}public AjaxService getAjaxService() {return ajaxService;}public void setAjaxService(AjaxService ajaxService) {this.ajaxService = ajaxService;}public String getPrefecture() {return prefecture;}public void setPrefecture(String prefecture) {this.prefecture = prefecture;}public void setAdArea(String adArea) {this.adArea = adArea;}public List<LabelValueBean> getOptionList() {return optionList;}public void setOptionList(List<LabelValueBean> optionList) {this.optionList = optionList;}}
[img][/img]