设为首页 加入收藏

TOP

一组Struts的选择测试题附答案(2)
2014-11-13 19:15:03 来源: 作者: 【 】 浏览:22
Tags:一组 Struts 选择 测试题 答案

(1)假设在helloapp应用中有一个hello.jsp,它的文件路径如下:
%CATALINA_HOME%/webapps/helloapp/hello/hello.jsp
那么在浏览器端访问hello.jsp的URL是什么 (单选)
选项:
(A) http://localhost:8080/hello.jsp
(B) http://localhost:8080/helloapp/hello.jsp
(C) http://localhost:8080/helloapp/hello/hello.jsp


(2)假设在helloapp应用中有一个HelloServlet类,它位于org.javathinker包下,那么这个类的class文件应该放


在什么目录下 (单选)
选项:
(A) helloapp/HelloServlet.class
(B) helloapp/WEB-INF/HelloServlet.class
(C) helloapp/WEB-INF/classes/HelloServlet.class
(D) helloapp/WEB-INF/classes/org/javathinker/HelloServlet.class


(3)假设在helloapp应用中有一个HelloServlet类,它在web.xml文件中的配置如下:

HelloServlet
org.javathinker.HelloServlet



HelloServlet
/hello

那么在浏览器端访问HelloServlet的URL是什么 (单选)
选项:
(A) http://localhost:8080/HelloServlet
(B) http://localhost:8080/helloapp/HelloServlet
(C) http://localhost:8080/helloapp/org/javathinker/hello
(D) http://localhost:8080/helloapp/hello


(4)客户请求访问HTML页面与访问Servlet有什么异同?(多选)
选项:
(A)相同:都使用HTTP协议
(B)区别:前者Web服务器直接返回HTML页面,后者Web服务器调用Servlet的方法,由Servlet动态生成HTML页面
(C)相同:前者Web服务器直接返回HTML页面,后者Web服务器直接返回Servlet的源代码。
(D)区别:后者需要在web.xml中配置URL路径。
(E)区别:前者使用HTTP协议,后者使用RMI协议。


(5)HttpServletRequest对象是由谁创建的 (单选)
选项:
(A)由Servlet容器负责创建,对于每个HTTP请求, Servlet容器都会创建一个HttpServletRequest对象
(B)由JavaWeb应用的Servlet或JSP组件负责创建,当Servlet或JSP组件响应HTTP请求时,先创建


HttpServletRequest对象


(6)从HTTP请求中,获得请求参数,应该调用哪个方法 (单选)
选项:
(A)调用HttpServletRequest对象的getAttribute()方法
(B)调用ServletContext对象的getAttribute()方法
(C)调用HttpServletRequest对象的getParameter()方法


(7)ServletContext对象是由谁创建的 (单选)
选项:
(A)由Servlet容器负责创建,对于每个HTTP请求, Servlet容器都会创建一个ServletContext对象
(B)由JavaWeb应用本身负责为自己创建一个ServletContext对象
(C)由Servlet容器负责创建,对于每个JavaWeb应用,在启动时,Servlet容器都会创建一个ServletContext对象


(8)jspForward1.jsp要把请求转发给jspForward2.jsp,应该在jspForward1.jsp中如何实现 (单选)
选项:
(A) jspForward2.jsp
(B)


(9)当浏览器第二次访问以下JSP网页时的输出结果是什么 (单选)



<%
int b=0;
a++;
b++;
%>


a:<%= a %>

b:<%= b %>


选项:
(A) a=0 b=0
(B) a=1 b=1
(c) a=2 b=1


(10)下面哪个说法是正确的 (单选)
选项:
(A) 对于每个要求访问maillogin.jsp的HTTP请求,Servlet容器都会创建一个HttpSession对象
(B)每个HttpSession对象都有惟一的ID。
(C)JavaWeb应用程序必须负责为HttpSession分配惟一的ID


(11)如果不希望JSP网页支持Session,应该如何办 (单选)
选项:
(A) 调用HttpSession的invalidate()方法
(B) <%@ page session= “false\”>


(12)在标签处理类中,如何访问session范围内的共享数据 (多选)
选项:
(A)在TagSupport类中定义了session成员变量,直接调用它的getAttribute()方法即可。
(B)在标签处理类TagSupport类中定义了pageContext成员变量,先通过它的getSession()方法获得当前的


HttpSession对象,再调用HttpSession对象的getAttribute()方法。
(C)pageContext.getAttribute(“attributename”,PageContext.SESSION_SCOPE)


(13)在下面的选项中,哪些是TagSupport类的doStartTag()方法的有效返回值 (多选)
选项:
(A) Tag.SKIP_BODY
(B) Tag.SKIY_PAGE
(C) Tag.eva l_BODY_INCLUDE
(D) Tag.eva l_PAGE


(14)以下代码能否编译通过,假如能编译通过,运行时得到什么打印结果?(单选)
request.setAttribute(\”count\”,new Integer(0));
Integer count = request.getAttribute(\”count\”);
选项:
A)不能编译通过 B)能编译通过,并正常运行
C) 编译通过,但运行时抛出ClassCastException


答案:
(1)C (2)D (3)D (4)A,B,D (5)A (6)C (7)C (8)B (9)C (10)B
(11)B (12)B,C (13)A,C (14)A


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇阿里巴巴入职以来心得体会与成长 下一篇以百度、腾讯、搜狗等的面试、和..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: