久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

javaweb學(xué)習(xí)_淺談request對象中g(shù)et和post的差異-創(chuàng)新互聯(lián)

閱讀目錄(Content)

創(chuàng)新互聯(lián)專注于班戈企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站,成都商城網(wǎng)站開發(fā)。班戈網(wǎng)站建設(shè)公司,為班戈等地區(qū)提供建站服務(wù)。全流程按需制作網(wǎng)站,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)

•1.get與post的區(qū)別

•1.1 get方法 jsp中的代碼form表單代碼


•1.2 action包中servlet的doGet方法中的代碼


•2.運行結(jié)果

•2.1 輸入數(shù)據(jù)


•2.2 打印出數(shù)據(jù)


•3.post方法

•4.對比

•4.1 在輸出頁面按下F12查看


•5.分析

1.get與post的區(qū)別

Get和Post方法都是對服務(wù)器的請求方式,只是他們傳輸表單的方式不一樣。

下面我們就以傳輸一個表單的數(shù)據(jù)為例,來分析get與Post的區(qū)別

1.1 get方法  jsp中的代碼form表單代碼

java web學(xué)習(xí)_淺談request對象中g(shù)et和post的差異

1.2 action包中servlet的doGet方法中的代碼

protected void doGet(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
  response.setContentType("text/html;charset=gbk");//設(shè)置響應(yīng)正文的mime類型
  request.setCharacterEncoding("gbk");//設(shè)置請求的編碼格式
  response.setCharacterEncoding("gbk"); 

  String username = request.getParameter("userName");//
  String password = request.getParameter("password");
  String sex = request.getParameter("sex");
  String classes = request.getParameter("class");
  String hobby[] = request.getParameterValues("hobby");// 獲取checkbox的數(shù)據(jù)保存到hobby數(shù)組中

  PrintWriter out = response.getWriter();
  
  if (hobby != null) {
   for (String x: hobby) {
    out.println("doGet被調(diào)用");
    out.println("name:"+username+"password:"+password+"sex"+sex+"classes"+classes);
    out.println("hobby:" + x);  
   }
  }else{
   out.println("此人沒愛好!"); 
  }
 }

新聞標(biāo)題:javaweb學(xué)習(xí)_淺談request對象中g(shù)et和post的差異-創(chuàng)新互聯(lián)
URL分享:http://sd-ha.com/article28/jchcp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、面包屑導(dǎo)航搜索引擎優(yōu)化、云服務(wù)器、網(wǎng)站策劃、網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管