´Ëʱ£¬Ó¦¸Ã´´½¨Webserver¡£Ê¹ÓÃtomcatserver´´½¨servlet
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * * @author ÕÔ³ç */ public class Ajax extends HttpServlet { /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ String old=request.getParameter("name"); if(old==null){ out.println("username²»ÄÜΪ¿Õ"); }else{ String name=new String(old.getBytes("ISO8859-1"),"gb2312"); System.out.println(name); if(name.equals("zhaochong")){ out.println("username["+ name+"]ÒѾ´æÔÚ¡£ÇëʹÓÃÆäËüusername"); }else{ out.println("username["+ name+"]ÉÐδ´æÔÚ£¬ÇëʹÓÃÆäËüusername"); } } } }
ÔÚ´´½¨servletµÄʱºò£¬½ö½öÐëÒª¸Ä¶¯processRequestº¯ÊýÖеÄÄÚÈÝ¡£´´½¨servletµÄʱºò£¬Çë×Ô¼ºÖ÷¶¯Éú³Éxml
ÒÔÉÏDemoÊÇÔÚNetBean IDEÉϽøÐеġ£¾¡¹ÜÕâôһ¸öСÑùÀý¡£·¢ÏÖÀïÃæÓкö඼²»¶®¡¡±È·½tomcatÓëglashfishµÄ²î±ð ÒÔ¼°xmlÎļþÀïÄÚÈݵĺ¬ÒåµÈµÈ¡£
¿´ÊÓƵµÄʱºò£¬ÑÛ¿´Æ«ÁË£¬ºöÂÔÁË ¿ª·¢»·¾³µÄÅäÖá£
×ܽá
ͨ¹ýÒÔÉÏÒ»¸öСÑùÀý£¬Äܹ»³õ²½Á˽âÒ»ÏÂAjaxÓ봫ͳҳÃæµÄ²î±ð¡£¸ü¼ÓÉîÈëµÄÀí½â£¬ÐëÒªÔÚ¶à´Î·´¸´£¬ÔÚÏîÄ¿ÖÐÓ¦Ó㬲ŸÉÊìÁ·ÕÆÎÕ¡£
¡¡