原文都是英文,是自己翻译的,如有不对的地方欢迎指正。

Q:What is ActionServlet?

什么是控制器(中央控制器)?

A:The class org.apache.struts.action.ActionServlet is the called the ActionServlet. In the  Jakarta Struts Framework this class plays the role of controller. All the requests to server goes through the controller.Controller is responsible for handling all the requests.

类class org.apache.struts.action.ActionServlet被叫做控制器。在Jakarta Struts Framework中,这个类扮演者控制者的角色。所有给服务器的请求都通过这个控制者。它负责处理所有的请求。

Q:How you will make available any Message Resources Definitions file to the Struts Framework Environment?

你如何使得任何对Struts Framework环境的信息资源定义文件可用?

A:Message Resources Definitions file are simple proerties files and these files contains the messages that can be used in the struts project Message Resources Definitions files can be added to the struts-config.xml file through<message-resources>tag . Example:

<message-resources parameter="MessageResources" />

信息资源定义文件是简单的属性文件,并且这些文件包含的信息可以被用在struts项目中。这些文件可以通过struts-config.xml中的<message-resources>标签添加。

Q:What is Action Class?

什么是Action(操作)类?

A:The Action is part of the controller. The purpose of Action Class is to translate the HttpServletRequest to the bussiness logic. To use the Action, we need to Subclass and overwritethe execute() method. The ActionServlet (commad) passes the parameterized class to Action Form using the execute() method. There should be no database interactions in the action. The action should receive the request, call business objects (which then handle database, or interface with J2EE.etc) and then determine where to go next. Even better, the business objects could be handed to the action at runtime(IoC style) thus removing any dependencies on the model. The return type of the execute method is AtionForward which is used by the Struts Framework to forward the request to the file as per the value of the returned ActionForward object.

Action(操作)是控制器的一部分。Action类的目的是把HttpServletRequest(请求对象)转换成业务逻辑。要用Action,我们需要继承和重写execute()方法。ActionServlet通过execute()方法把参数化类传递给Action Form(表单)。在这个Action中应该没有任何数据库的互动。这个action应该接受请求,调用业务对象(在此控制数据,或者J2EE界面,等等),并决定接下来做什么。甚至,业务对象可以在运行时被action控制从而消除对model的依赖(IoC)。(对spring不熟,此处翻译可能有误)。execute方法的返回类型是ActionForward,作为每个ActionForward对象的返回值,Struts Framework用它来告诉请求指向的文件.

Q:Write code of any Action Class?

写出任意Action类的代码。

A:Here is the code of Action Class that returns the ActionForward object.

TestAction.java

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;public class TestAction extends Action {public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{return mapping.findForward("testAction");}
}

Q:What is ActionForm?

什么是ActionForm?

A:An ActionForm is a JavaBean that extends org.apache,struts.action.ActionForm maintains the session state for web application and the ActionForm object is automatically populated on the server side with data entered from a form on the client side.

一个ActionForm就是一个JavaBean,它继承org.apache.struts.action.ActionForm。ActionForm在网络应用中保持session状态,并且ActionForm对象自动把客户端的表单数据填送给服务器端。

Q:What is Struts Validator Framework?

什么是Struts验证框架?

A:Struts Framework provides the functionality to validate the form data.It can be use to validate the data on the users browser as well as on the server side. Struts Framework emits the java scripts and it can be used validate the form data on the client browser. Server side validation of form can be accomplished by sub classing your From Bean with DynaValidatorForm class.

Struts验证框架提供验证表单数据的功能。它可以验证用户浏览器和服务器上的信息。Struts框架使用javascript来验证浏览器端数据。服务器端的表单验证由Form Bean的子类DynaValidatorForm类完成。

验证框架由David Winterfeldt开发,作为第三方加入到Struts.现在验证框架是Jakarta Commons项目的一部分,并且在不在sturs中都可以使用。验证框架与struts紧密结合,可以不做任何其他设置直接使用。

Q:Give the Details of XML files used in Validator Framework?

给出在验证框架中使用XML文件的细节。

A:The Validator Framework uses two XML configuration files validator-rules.xml and validation.xml .The validator-rule.xml defines the standard validation routines, these are reusable and used in validation.xml to define the form specific validations. The validation.xml defines the validations aplied to a form bean.

验证框架由两个xml文件组成validator-rules.xml和validation.xml。validator-rules.xml定义验证的基本规则,他们是可在validation.xml定义表单具体验证时重复使用的。validation.xml为表单项定义验证项。

Q:How you willl display validation fail errors on jsp page?

在jsp页面中如何显示验证错误信息。

A:Follwing tag displays all the errors:

<html:errors/>

Q:How you will enable front-end validation based on the xml in validation.xml?

如何使得前端验证基于validation.xml的xml定义。

A:The <html:javascript>tag to allow front-end validation based on the xml in validation.xml. For example the code <html:javascript formName="logonForm" dynamicJavascript="true" staticJavascript="true" />generates the client side java script for the form "logonForm" as defined in the validation.xml file. The <html:javascript>when added in the jsp file generates the client site validation script.

<html:javascript>标签使得前端验证基于validation.xml的xml定义。举例来说,代码<html:javascript formName="logonForm" dynamicJavascript="true" staticJavascript="true" />使得表单logonForm通过使用客户端javascript使用validation.xml文件中定义的验证。当<html:javascript>加入到jsp页面中,就构建了客户端验证script。

国外的一些struts面试题1相关推荐

  1. 【quant!quant!!】一家国外金融公司的quant面试题

    一家国外金融公司的quant面试题 http://www.btsmth.com/show_topic.php?en_name=CoderInterview&gid=2255 楼主 lins05 ...

  2. 艾为数字ic面试题_国外的数字IC面试题(非常详细,有答案)

    原标题:国外的数字IC面试题(非常详细,有答案) 这是由EETOP网友lswujun上传的国外数字IC面试题. 内容相对比较基础,有答案. 内容包括: Questions and Answers ar ...

  3. STRUTS模拟试题

    1什么是MVC模式,是否所有JSP应用都该采用MVC模式,请说明理由? 2. 在Struts应用的模型中包含哪些组件?(多选) (A) JSP (B) Servlet (C) ActionServle ...

  4. 一道Struts面试题

    题目是这样的 有两张表 一张为新闻类别表 有2个字段: nid(pk) sort 有一张新闻内容表 有三个字段 cid(pk) nid(fk) title content 要求通过下拉列表框的方法选择 ...

  5. [转载] JAVA面试题大全(part_1)

    参考链接: 对Java中派生类方法更严格的访问 JAVA面试题大全(part_1) 1.面向对象的特征有哪些方面 (1)抽象: 抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目 ...

  6. JAVA面试题大全(part_1)

    JAVA面试题大全(part_1) 1.面向对象的特征有哪些方面 (1)抽象: 抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问题,而只 是 ...

  7. JAVA程序员笔试面试题汇总及答案 .

    1.面向对象的特征有哪些方面 (1)抽象: 抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问题,而只 是选择其中的一部分,暂时不用部分细节. ...

  8. 一份超详细的IBM公司JAVA基础面试题附答案以及解析(题库)

    第一章 Java概述 笔试题 一.填空题 1.[基础题]Java是一种先 编译 后 解释 运行的语言. 二.选择题 三.名词解释 1.[基础题]J2SE:Java 2 Standard Edition ...

  9. java面试题连接集锦

    2010年9月几道最新Java面试题 文章分类:招聘求职 ---------九月更新 JAVA面试题 带答案的java面试题 欢迎参考 Java的几个基础面试题 带答案的 如下代码中finally中的 ...

最新文章

  1. android sqlite用户注册代码,用户名和密码登录android登录sqlite
  2. android singleTop 不起作用
  3. 长江存储发布PCle4.0 固态硬盘致态TiPro7000,顺序读取7400MB/s
  4. Java基础---数组内容详解
  5. Windows和VMware下ubuntu切换界面的快捷键
  6. Java高级面试题解析(二):百度Java面试题前200页(精选)
  7. 骗子丛生的58正失去“神奇”魔法
  8. python应用广泛吗_入门迅速、应用广泛、月薪两万,马哥Python前景为什么这么好?...
  9. 计算机函数公式 加法,excel怎样使用加法函数公式
  10. 2016年U盘启动盘制作工具哪个好用?看U盘启动盘排行榜!
  11. 不得不学,从零到一搭建ELK日志,Docker环境下部署 logstash工具
  12. Codeforces Gym 100015A Another Rock-Paper-Scissors Problem 找规律
  13. windows配置代理
  14. 微软认知服务应用秘籍 – 漫画翻译篇
  15. 志在必得的。。。。失败。。。
  16. 蓝牙鼠标链接Win10需要“输入MI MOUSE BT3.0的PIN”的解决方案
  17. js 模拟浏览器的并行请求限制
  18. 网络安全一哥的流量分析服务非常好
  19. Small Object Detection using Context and Attention
  20. 年纪越大约有资历,日本职场不存在“年轻饭”

热门文章

  1. 《失业的程序员》(十三):平衡
  2. 【PA2014】【BZOJ3714】Kuglarz
  3. Centos6.5设置静态IP并能进行联网
  4. RHEL 6 修改网卡名称
  5. vnpy文件结构说明
  6. matlab做概率论题,Matlab 概率论与数理统计.doc
  7. 10个让人眼花缭乱的 HTML5 和 JavaScript 特效,Flash情何以堪啊~
  8. AndroidStudio问题: Missing essential plugin
  9. 移动硬盘无法重命名问题的解决之道(win7)
  10. vue项目引入富文本编辑,图片上传/视频上传