3 doGet() 和 doPost() 的区别?

题目

3 doGet() 和 doPost() 的区别?

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

开发JavaWeb应用程序时,创建一个Servlet,该Servlet重写了其父类的doGet()和doPost()方法,那么其父类可能有( )

A、GenericServlet

B、ServletResponse

C、ServletRequest

D、HttpServlet


正确答案:AD

第2题:

什么情况下调用doGet()和doPost()?


正确答案:

 

Jsp 页面中的FORM. 标签里的method 属性为get 时调用doGet(),为post 时调用

doPost()。

第3题:

在J2EE中,在Servlet1中的doGet和doPost方法中只有如下代码:request.setAttribute("jb","aptech");response.sendRedirect("http://localhost:8080/servlet/Servlet2");那么在Servlet2中使用()可以把属性jb的值取出来。

A.Stringstr=request.getAttribute("jb");

B.Stringstr=(String)request.getAttribute("jb");

C.Objectstr=request.getAttribute("jb");

D.取不出来


参考答案:D

第4题:

下列论述HTTP协议中doGet和doPost方法的命题中,哪些是正确的()

  • A、doGet适用大量数据传输
  • B、doPost适用大量数据传输
  • C、默认情况下doPost将Form中参数和值显示在URL中
  • D、默认情况下doGet将Form中参数和值显示在URL中

正确答案:B,D

第5题:

下面关于Servlet生命周期,说法不正确的是()。 

  • A、 在创建自己的Servlet时候,应该在初始化方法init()方法中创建Servlet实例
  • B、 在Servlet生命周期的服务阶段,执行service()方法,根据用户请求的方法,执行相应的doGet()或是doPost()方法
  • C、 在销毁阶段,执行destroy()方法后系统立刻进行垃圾回收
  • D、 destroy()方法仅执行一次

正确答案:A,C

第6题:

下面哪项不是Servlet处理客户请求的方法()

A、doPost()

B、doGet()

C、service()

D、destroy()


参考答案:D

第7题:

Servlet的基本架构

public class ServletName extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

}

}

1、用String的方法将数据类型转换为String。


正确答案:

 

1、String.valueOf(1.23)

第8题:

在J2EE中,对于HttpServlet类的描述,正确的是()。

A.我们自己编写的Servlet继承了HttpServlet类,一般只需覆盖doPost或者doGet方法,不必覆盖service()方法。因为一个service()方法是空的

B.HttpServlet类扩展了GenericServlet类,实现了GenericServlet类的抽象方法service()

C.HttpServlet类有两个service()方法

D.我们自己编写的Servlet继承了HttpServlet类,一般只需覆盖doPost或者doGet方法,不必覆盖service()方法。因为一个service()方法会调用doPost或者doGet方法


参考答案:B, C, D

第9题:

下面哪个方法不是HttpServlet类:()

  • A、protected void doGet(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception ,java.io.IOException
  • B、protected void doPost(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOException
  • C、protected void doHead(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOException
  • D、protected void doReceive(HttpServletRequest reg,HttpServletResponse res) throws ServletException,java.io.IOException

正确答案:D

第10题:

在J2EE中,对于HttpServlet类的描述,错误的是()。

  • A、我们自己编写的Servlet继承了HttpServlet类,一定需覆盖doPost或者doGet
  • B、Httpservlet类扩展了GenericServlet类,实现了GenericServlet类的抽象方法
  • C、Httpservlet类中处理客户请求和响应时所使用的两个接口是:HttpServletRequest和HttpServletResponse
  • D、我们自己编写的servlet继承了Httpservlet类,一般只需要覆盖doPost或doGet方法,不必覆盖servive()方法,因为一个service()方法会调用doPost或者doGet方法

正确答案:A

更多相关问题