package cc;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import spring.Container;
import faced.XtFac;
/**
* ClassName:mhxmAction <br/>
* Date: 2014-11-25 下午3:45:30 <br/>
* @author yy
* @since JDK 1.6
*/
public class mhxmAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
String xm = request.getParameter("xm")==null?"":request.getParameter("xm").trim();
List ls=new ArrayList();
List lsxx=new ArrayList();
XtFac xt = (XtFac) Container.getContext().getBean("xtFac");
net.sf.json.JSONArray json = new net.sf.json.JSONArray();
net.sf.json.JSONObject jsonObject =new net.sf.json.JSONObject();
if(xm!=null&&!xm.equals("")){
ls = xt.getxm(xm);
}
for(int i=0;i<ls.size();i++){
Object[] obj=(Object[])ls.get(i);
jsonObject.put("name", obj[0]);
jsonObject.put("id", obj[1]);
json.add(jsonObject);
}
PrintWriter out;
StringBuffer sb=new StringBuffer();
sb.append(json.toString());
try {
response.setContentType("text/html;charset=GBK");
out = response.getWriter();
out.write(sb.toString());
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
- 1
- 2
前往页