程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> ËµËµservlet(Ò»)

˵˵servlet(һ)

編輯:關於JSP

1.ÒªÓÃ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µÈ¿É¸Ä±äÊý¾Ý´æ´¢µÄµØ·½
»¹ÓÐһЩ¶«Î÷Ï´ÎÔÙ½²°É

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved