1、页面
<%@ page language=\"java\" import=\"java.util.*\" pageEncoding=\"UTF-8\"%> <%@ tagliburi=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\" %>
2、servlet类 packagecom.sdo.cms.zmhd.web.command; importjava.io.IOException; importjava.io.PrintWriter; importjava.util.ArrayList; importjava.util.List; importjavax.servlet.ServletException; importjavax.servlet.http.HttpServlet; importjavax.servlet.http.HttpServletRequest; importjavax.servlet.http.HttpServletResponse; importnet.sf.json.JSONObject; public class GetAndPostExampleServlet extends HttpServlet { /** * Constructor of the object. */ publicGetAndPostExampleServlet() { super(); } /** * The doGet method of the servlet. out.print(this.getClass()); out.println(\ out.println(\" \"); out.println(\"\"); out.flush(); out.close(); } /** * The doPost method of the servlet. ==========================================\"+ jsonComment.toString()); list.add(jsonComment); ret.put(\"list\ String asd=request.getParameter(\"asd\"); PrintWriter out=response.getWriter(); out.print(ret.toString()); out.close(); } } 3、web配置文件(其中里面字体放大、颜色 有改变的是ajax信息提交需要的部分) classpath:/applicationContext-resources.xml classpath:/applicationContext-dao.xml classpath:/applicationContext-service.xml classpath*:/applicationContext.xml /WEB-INF/applicationContext*.xml /WEB-INF/xfire-servlet.xml /WEB-INF/security.xml org.apache.catalina.ssi.SSIServlet 因篇幅问题不能全部显示,请点此查看更多更全内容
* * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException { response.setContentType(\"text/html\"); PrintWriter out = response.getWriter(); out .println(\"\"); out.println(\"\"); out.println(\"
* * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException { response.setContentType(\"text/xml\"); response.setCharacterEncoding(\"UTF-8\"); String searchKeyWord2=request.getParameter(\"searchKeyWord\"); String searchKeyWord = java.net.URLDecoder.decode(searchKeyWord2, \"utf-8\"); JSONObject ret =new JSONObject(); List