ajax后台处理返回json值示例代码
public ActionForward xsearch(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String parentId = request.getParameter("parentId");
String supplier = request.getParameter("supplier");
List itemList = new ArrayList();
if(parentId.equals("")){
parentId="0";
}
Map map=new TawApTreeServlet().getTypeList(parentId, supplier);
for (Iterator rowIt = map.keySet().iterator(); rowIt.hasNext();) {
String id = (String) rowIt.next();
TawCommonsUIListItem uiitem = new TawCommonsUIListItem();
uiitem.setItemId(id);
uiitem.setText((String)map.get(id));
uiitem.setValue(id);
itemList.add(uiitem);
}
response.setContentType("text/xml;charset=UTF-8");
// 返回JSON对象
response.getWriter().print(JSONUtil.list2JSON(itemList));
return null;
}相关阅读:
JS实现下拉菜单赋值到文本框的方法
JavaScript设计模式之工厂模式和构造器模式
基于JQuery实现图片上传预览与删除操作
C# 函数覆盖总结学习(推荐)
Linux中安装使用RXVT命令行终端窗口程序的教程
Html+CSS浮动的广告条实现分解
Win7/Win8.1升级Win10后开始菜单无法使用等问题仍未解决
用MyEclipse配置DataBase Explorer(图示)
win10不兼容Edius该怎么处理?让Edius正常运行的技巧
在Linux下实现批量屏蔽IP地址的方法
css实现的交互小三角箭头图标
Jjcarousellite 实现图片列表滚动的简单实例
Linux给文件或目录创建软链接或硬链接的方法
基于jquery的网站幻灯片切换效果焦点图代码