jquery json ajax例子2联动
后台/** * * @description 大分をわった、中分リスト内容をわる。<br> * @return JSONString * @note なし */ public String changeCustGyoMClassList() { // :中分リスト作成 custGyoMClassList = callSearchNewService.getCustGyoMClassList(Integer.parseInt(selectedBClass)); try { JsonUtil.sendJson(custGyoMClassList); } catch (IOException e) { if (log.isErrorEnabled()) { log.error(e); } } return null; }package jp.co.syspro.common.util;import java.io.IOException;import javax.servlet.http.HttpServletResponse;import net.sf.json.JSONArray;import org.apache.struts2.ServletActionContext;public class JsonUtil {/** * jsonデタる * * @param obj * デタ * @throws IOException */public static void sendJson(Object obj) throws IOException {JSONArray json = JSONArray.fromObject(obj);HttpServletResponse response = ServletActionContext.getResponse();response.setCharacterEncoding("UTF-8");response.getWriter().write(json.toString());}}