// StarInfoServlet package com.wilson.sun.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.wilson.sun.bean.StarBean; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class StarInfoServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // set the Character Encoding response.setCharacterEncoding("utf-8"); PrintWriter out = response.getWriter(); List<StarBean> stars = new ArrayList<StarBean>(); stars.add(new StarBean("1","水瓶座")); stars.add(new StarBean("2","双鱼座")); stars.add(new StarBean("3","白羊座")); stars.add(new StarBean("4","金牛座")); stars.add(new StarBean("5","双子座")); stars.add(new StarBean("6","巨蟹座")); stars.add(new StarBean("7","狮子座")); stars.add(new StarBean("8","处女座")); stars.add(new StarBean("9","天秤座")); stars.add(new StarBean("10","天蝎座")); stars.add(new StarBean("11","射手座")); stars.add(new StarBean("12","魔羯座")); JSONArray arr = JSONArray.fromObject(stars); //out.printf("{stars: [{ids:'%s',star:'%s'}]}", "1", "aaa"); //System.out.println(arr); //out.printf("{/"stars/": %s}", arr); out.print(arr); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); } }
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css" mce_href="ext/resources/css/ext-all.css"/> <mce:script type="text/javascript" src="ext/adapter/ext/ext-base.js" mce_src="ext/adapter/ext/ext-base.js"></mce:script> <mce:script type="text/javascript" src="ext/ext-all.js" mce_src="ext/ext-all.js"></mce:script> <mce:script type="text/javascript"><!-- Ext.onReady(function(){ var pnlBlur = new Ext.FormPanel({ labelWidth: 75, url:'save-form.php', frame:true, title: '模糊查找', bodyStyle:'padding:5px 5px 0', width: 350, defaults: {width: 230}, defaultType: 'textfield', waitMsgTarget: true, items: [{ //fieldLabel: '模糊查找', name: 'txtBlur', emptyText:'可输入多名车友姓名,用逗号隔开……', //allowBlank:false } ], buttons: [{ text: 'go!', disabled: false, handler: function(){ pnlBlur.getForm().submit({ url:'testBlur.do', waitMsg:'Loading', submitEmptyText: false}); } }] }); pnlBlur.render(document.body); var proxy = new Ext.data.HttpProxy({ url: 'http://localhost:9090/testdemo/starinfo.do' }); var store = new Ext.data.JsonStore({ proxy: proxy, //url: 'http://localhost:9090/testdemo/starinfo.do', //root: 'stars', idProperty: 'id', fields: ['id','star'] }); var pnlPara = new Ext.FormPanel({ labelWidth: 75, url:'save-form.php', frame:true, title: '参数查找', bodyStyle:'padding:5px 5px 0', width: 350, defaults: {width: 230}, defaultType: 'combo', waitMsgTarget: true, items: [{ name: 'cboGroup', emptyText:'所在车组', selectOnFocus:true, mode: 'local' },{ name: 'cboDistrict', emptyText:'区域' },{ name: 'cboGender', emptyText:'性别' },{ name: 'cboBlood', emptyText:'血型' },{ name: 'cboStar', emptyText: '星座', store: store, mode: 'remote', editable: false, triggerAction: 'all', valueField: 'id', displayField: 'star' //autoLoad: false } ], buttons: [{ text: 'go!' }] }); pnlPara.render(document.body); }); // --></mce:script> </head> <body> <%-- <form action="starinfo.do" method="post"> <input type="submit" value="测试starinfo.do" /> </form> --%> </body> </html>