ssh试题.doc
《ssh试题.doc》由会员分享,可在线阅读,更多相关《ssh试题.doc(17页珍藏版)》请在冰豆网上搜索。
测试卷
(java)
一、选择题(60分)
1)
在Struts实现的MVC框架中,(a)类是包含了excute方法的控制器类,负责调用模型的方法,控制应用程序的流程。
a)
Action
b)
EJB
c)
ActionServlet
d)
JSP
2)
在基于Struts框架的Web应用中,下面关于Action类的说法正确的是(c)。
a)
Action类属于模型组件
b)
Action类主要用来完成实际的业务逻辑
c)
Action类负责调用模型的方法,更新模型的状态,并帮助控制应用程序的流程
d)
在Web应用启动时会自动加载所有的Action实例
3)
在基于Struts框架的Web应用中,下面关于ActionFormBean的说法正确的是(b)。
a)
ActionFormBean用来完成一些实际的业务逻辑
b)
Struts框架利用ActionFormBean来进行视图和控制器之间表单数据的传递
c)
ActionForm负责调用模型的方法,更新模型的状态
d)
ActionFormBean包含一些特殊的方法,reset()用于验证表单数据validate()将其属性重新设置为默认值
4)
分析ActionBean的execute方法:
publicActionForwardexecute(ActionMappingmapping,ActionFormform,
HttpServletRequestrequest,HttpServletResponseresponse){
ActionErrorserrors=newActionErrors();
if(!
udao.check(loginform)){
errors.add("login",newActionMessage("error.login"));
returnmapping.findForward("failure");
}
}
完成以上的功能,应在下划线上填入(c)。
a)
this.saveErrors(request,errors);
b)
this.saveErrors(reponse,errors);
c)
this.addErrors(request,errors);
d)
this.addErrors(reponse,errors);
5)
在Struts配置文件中,(a)元素的processorClass属性用于配置RequestProcessor类。
a)
b)
c)
d)
6)
Action类的execute方法返回的ActionForward对象name属性必须与struts-config.xml中元素的(b)属性匹配。
a)
forward
b)
name
c)
path
d)
redirect
7)
在Struts应用中,要在网页上输出personbean对象的userName属性值,下列代码(b)是正确的。
a)
printname="personbean"property="userName"/>
b)
writename="personbean"property="userName"/>
c)
messagename="personbean"property="userName"/>
d)
writename="personbean"property="userName"/>
8)
以下代码定义了一个Vector类型的集合变量Animals:
<%
Vectoranimals=newVector();
animals.addElement("Dog");
animals.addElement("Cat");
animals.addElement("Bird");
request.setAttribute(“animals”,animals);
%>
现要求通过iterate>标签遍历该集合中的元素,并将每个元素的内容输出到网页中,下列代码正确的是(b)。
a)
iterateid="animals"name="element">
writename="element"/>
iterate>
b)
iterateid="element"name="animals">
writename="element"/>
iterate>
c)
iterateid="animals">
writename="element"/>
iterate>
d)
iterateid="element"name="animals">
writename="animals"/>
iterate>
9)
分析ActionFormBean的validate方法:
publicActionErrorsvalidate(ActionMappingactionMapping,
HttpServletRequesthttpServletRequest){
ActionErrorserrors=newActionErrors();
if((userName==null)||(userName.length()<1)){
}
returnerrors;
}
以上方法完成的功能为:
若用户没有在表单中输入姓名就提交表单将生成表单验证错误。
在下划线上填入(b)。
a)
errors.add("username");
b)
errors.add("username",newActionMessage("Enterusername"));
c)
errors.add(newActionMessage("Enterusername"),"username");
d)
errors.add(ActionMessage("Enterusername"));
10)
在struts开发中有页面内容:
method=add”>添加
method=modify”>修改
完成struts-config.xml的配置
path="/base"
type="struts.action.BaseAction"/>
在下划线上填入(b)。
a)
parameter="action"
b)
parameter="method"
c)
attribute="method"
d)
attribute="action"
11)
在hibernate中,不属于主键生成方式的是(c)。
a)
Assigned
b)
identity
c)
nature
d)
squence
12)
在hibernate开发中有如下内容:
StringHQL="deleteUsersuswhereus.usersId=?
";
Queryq=session.createQuery(HQL);
q.setString(0,id);
在下划线上填入(a)。
a)
q.executeUpdate();
b)
q.list();
c)
q.executeQuery();
d)
q.execute();
13)
在hibernate双向一对多关系中,
address.hbm.xml中关联关系内容如下:
--key表示TPerson对应的addressid-->
--集合中对应的每个对象-->
对应person.hbm.xml联关系内容正确的是(a)。
a)
b)
c)
d)
14)
在hibernate的多对多关系中,对inverse属性描述正确的是(d)。
a)
关系双方都在节点中设置inverse="true"属性
b)
关系双方都在节点中设置inverse="false"属性
c)
关系双方都在节点中去掉inverse属性
d)
一方在节点中设置inverse="false"属性,另一方不设置
15)
在hibernate开发中,关于POJO类对象的状态说法不正确的是(d)。
a)
自由状态(Transient):
实体在内存中自由存在,与数据库中的记录无关
b)
持久状态(Persistent):
实体处于由Hibernate框架所管理的状态,