最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
说说servlet(一)
时间:2022-07-02 17:54:18 编辑:袖梨 来源:一聚教程网
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等可改变数据存储的地方
还有一些东西下次再讲吧
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等可改变数据存储的地方
还有一些东西下次再讲吧
相关文章
- 96345如何助你快速找到钟点工 03-29
- 我的常德app如何交学费 03-29
- 如何登录网易163免费邮箱 03-29
- 腾讯会议直达入口地址在哪 03-29
- 小宇宙app如何标记喜欢的单集 03-29
- 如何查看12306已完成订单详情 03-29