¡¡¡¡servlet1.ÒªÓÃservletÊ×ÏÈÒªÔÚapplicationÖÐÒýÈëservlet.jar
2.È»ºóÒªÔÚ.javaÎļþÖÐ
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.PrintWriter; //Õâ¾äimport¿ÉÊÓ¾ßÌåÇé¿öÒýÈë
3.½éÉÜÒ»ÏÂservletÖеļ¸¸ö³£Óõķ½·¨
a) protected void service(HttpSerlvetRequest req,HttpServletResponse res) throws ServletException,IOException{}
Èç¹û±»overwriteÁË£¬Ôò¿ÉÄܲ»»áµ÷ÓÃdoXXX method¡£
b)protected void doGet(HttpSerlvetRequest req,HttpServletResponse res) throws ServletException,IOException{}
ÌØÕ÷1£ºsafe and idempotent. 2£ºOnly ASCII (text) data can be sent to server with GET method. 3£ºeasy to bookmarks.
Ö÷Òª×÷Ó㺻ñÈ¡Êý¾Ý£¬¶ÔÊý¾Ý²»×÷¸Ä±ä
c)protected void doPost(HttpSerlvetRequest req,HttpServletResponse res) throws ServletException,IOException{}
ÌØÕ÷1£ºnot safe and idempotent. 2disallow bookmarks.
Ö÷Òª×÷Ó㺴«Êäform data£¬´óÅúÁ¿µÄÊý¾Ý£¬³£ÓÃÔÚbbsµÈ¿É¸Ä±äÊý¾Ý´æ´¢µÄµØ·½
»¹ÓÐһЩ¶«Î÷Ï´ÎÔÙ½²°É
˵˵servlet(һ)
80¿á¿áÍø 80kuku.com