- 浏览: 150444 次
- 性别:
- 来自: 武汉
文章分类
最新评论
-
mathlpz:
JSP_Struts标签 html:select option基本用法 -
phil09s:
还有一篇相当不错的教程:http://lavasoft.blo ...
commons-logging log4j的联系区别 -
phil09s:
灰常不错的教程,配合http://sammor.iteye.c ...
commons-logging log4j的联系区别
Below are some of the important Java Struts interview questions and answers gathered from various users.
What Are Struts?
Struts framework is a prerequisite for a professional web application. It is the framework that every web application developer should have in his or her toolbox. The Struts framework provides the scaffolding for the workings of a web application. Published standards and its proven design pattern will enable your application to have an expansible development pattern.
The core of the framework is a flexible control layer, adhering to standard technologies such as Jave Servlets, JavaBeans, ResourceBundles, and XML. Its technology also meets the standards of various Jakarta Commons packages, making it a universal framework that could be easily utilized in any setting. The framework supports application architectures based on the Model 2 approach. This provides a variety and offers web application developers
a choice aside from the more common Model-View-Controller (MVC) design paradigm.
Struts provide the Controller component. However, the Model and the View is based on integration and interaction with
other technologies. The interaction of standard data access technologies, like JDBC and EJBC, with Struts provides
the Model for the framework. Other third party packages like Hibernate, iBATIS or Object Relational Bridge also serve this purpose.
The View component is produced in much the same way as the Model. Common presentation systems like JavaServer Pages,
not excluding JSTL and JSF, Velocity Templates and XSLT are compatible with Struts.
Explain Jakarta Struts Framework?
The development of web based application of any size and scale is possible with Jakarta Struts framework. This open source
implementation of MVC (Model-View-Controller) allows for robust architecture. Thus it facilitates the design of scaleable,
reliable web applications with Java by making the design process much simpler.
Define Action Servlet.
Action Servlet is the class org.apache.struts.Action Servlet. This class is the controller in the Jakarta Struts Framework.
As the medium of delivery, the controller handles all requests to the server.
How To Make Available Message Resources Definitions to the Struts Framework?
Message Resources Definitions files are added to the struts-config.xml file through the <message-resources/> tag.
This is because the Message Resources Definitions files are simple .properties files that contain messages usable in the struts project.
What Is Action Class?
All database/business processing happens in the Action Class. All database related stuffs are encouraged to be performed
in the Action Class. The Action Class wraps around the business logic and it is a part of the Model. It serves to translate
the HttpServletRequest to the business logic. Using the Action requires us to Subclass and to overwrite the execute() method.
The parameterized class is bypassed by the ActionServlet (commad) to ActionForm through the execute() method.
ActionForward is the return type for the execute method. In turn, the Struts Framework forwards requests to the file
using the ActionForward according to the value of the returned ActionForward object.
Action Form
An ActionForm is a JavaBean functioning to extend org.apache.struts.action.ActionForm. When a client fills in a form and
entered it, the ActionForm object will be automatically populated on the server side. The ActionForm also functions to keep the session state ongoing for web application.
1. What is Struts?
Struts is an open source software that helps developers to easily build web application. It is a web page development framework which comprises of Java Servlets, Java Server Pages, custom tags, and message resources into a single framework. It is also a cooperative platform for development teams as well as independent developers.
2. Explain the components of Struts?
Struts is based on the MVC design pattern and its components can be categorized into:
Model: Components like business logic / business processes and data are parts of this.
View: It contains JSP, HTML etc.
Controller: Action Servlet of Struts is part of Controller components which works as front controller to handle all the requests.
3. How will we make any Of the Message Resources Definitions file available to the Struts Framework Environment?
Message Resources Definitions file are simple property files which consists of messages that can be used in the struts applications. Message Resources Definitions files can also be added to the struts-config.xml file using <message-resources /> tag.
E.g. <message-resources parameter="Message Resources" />
4. What is Struts Validator Framework?
Struts Framework provides the functionality to validate the form data. This can be used to validate data on both the client side as well as server side. It emits the java scripts and can be used to validate data on the user’s browser and incase of server side validation, it is done by sub classing the From Bean with DynaValidatorForm class.
The Validator framework comes integrated with the Struts Framework and can be used without doing any extra change in settings.
5. Is struts thread safe?
Struts is thread safe as well as thread-dependant. Light-weight Action object handles the response to a request instead of individual servlets. The Action class is instantiated only once and lets the other requests to be threaded through the original object available. This technique helps to provide the best possible throughput and conserves resources. A properly-designed application will exploit this further by routing related operations through a single Action.
6. What are the core classes of the Struts Framework?
The core classes of Struts framework are:
ActionServlet is the back bone of the whole web application.
ActionForm is a Java bean that associates one or more ActionMappings.
The business logic is wrapped by the Action class which provides an interface to the Model of the application.
ActionMapping is used to provide mappings for Objects to Actions.
ActionForward represent the destination for the controller.
7. What are the different kinds of actions in Struts?
The different kinds of actions in Struts are as follows:
a. ForwardAction.
b. IncludeAction.
c. DispatchAction.
d. LookupDispatchAction.
e. SwitchAction.
8. What is Action Class?
The Action Class is a part of the Model. Its purpose is to translate the HttpServletRequest to the business logic and use the Action, we need to have a Subclass and overwrite the execute() method, In which all the database/ business processing are done. The ActionServlet (command) passes the parameterized class to Action Form using the execute() method and its return type is used by the Struts Framework to forward the request to the file according the value of the returned ActionForward object.
9. What are the various Struts tag libraries?
The various Struts tag libraries are:
a. Bean tag library – to access JavaBeans and their properties.
b. HTML tag library - to give standard HTML output, like forms, text boxes, etc.
c. Logic tag library – in order to generate conditional output, iteration capabilities and flow management.
d. Tiles or Template tag library - for those application using tiles.
e. Nested tag library – in order to use the nested beans in the application.
10. How the exceptions are handled in struts?
Exceptions in Struts are handled in two ways:
a. Programmatic exception handling: It is the explicit try/catch blocks in the code that can throw exception. It works well when any error occurs in the custom value
b. Declarative exception handling: In this we either define <global-exceptions> handling tags in the struts-config.xml or exception handling tags within <action></action> tag. It works well when error occurs in custom page and applies only to exceptions thrown by Actions.
11. What are the contents of web.xml and struts-config.xml? Explain the difference between them.
The web.xml file contains the information used by servlets and JSPs, having the description of the application, mapping information about servlets and URL, JSP configuration information, error page information without the exceptions.
The struts-config.xml file contains information about struts framework at the time of deploying the web application. It includes information about form bean, action mappings, controller information containing the buffer size, content type, etc.
12. What is SwitchAction & ForwardAction in struts?
A SwitchAction switches between modules and forwards the control to the URL specified in the new module. There are two parameters namely page, to which control is forwarded after switching and prefix that specifies the module to which the control is switched.
A ForwardAction is used to forward a request to the specified URL, represented as a destination to the controller to which it is sent after the action is completed.
13. What is Struts Flow?
Struts Flow is a port of Cocoon's Control Flow to Struts in order to allow complex workflow, like multi-form wizards, which is easily implemented using continuations-capable JavaScript. It provides the ability to describe the order of web pages that have to be sent to the client, at any given point of time in an application.
14. Why is ActionForm a base class rather than an interface?
Making ActionForm a class gives advantage of the single inheritance restriction of Java in order to make difficult for people to do things that they are not supposed to.
However, if ActionForm is implemented as interface encourages matching of property types to the underlying business tier, violating one of the important purpose of ActionForm and also encourages using of existing DAO objects which violates MVC design pattern.
发表评论
-
14、ssh面试经典
2011-11-07 10:50 10441. Hibernate工作原理及为什么要用?原理:1. ... -
12、十大面试超基础问题
2011-09-30 10:03 8641. Java中的异常处理机制 ... -
11、hibernate下著名的延迟加载问题和1:N问题
2011-05-11 17:52 7072问题描述: 如果延迟的操作是发生在CRUD的操作所在的s ... -
10、线程相关
2011-04-18 14:20 1012Thread.sleep()、Thread.wait() 和T ... -
9、说下数据库范式;设计模式的分类
2011-04-18 14:03 12821.1 第一范式(1NF)无重复的列 比如oracle中的d ... -
8、编程实现统计文本文件中某个单词的出现频率,并输出统计结果
2010-08-31 16:40 2354package _0831; import java.io. ... -
7、常见面试口语提问问题汇总
2010-08-28 17:50 2393一、please introduce yourself. ... -
6、假设字符串类似这样的aba和aab就相等,先在随便给你两组字符串,判断他们是否相等
2010-08-28 11:27 3521package _0828; import java.i ... -
5、编程题:创建一个静态方法:给他传入一个对象,请循环打印出改对象所在类的类名和
2010-08-27 16:03 1653package _0827; import java.l ... -
4、编程题目:写一个快速排序
2010-08-17 16:50 1039package _0817; import java.u ... -
3、说说ArrayList、LinkedList的区别
2010-08-13 16:18 1017笔试面试题目搜集 ... -
2、编程题目:写一个单例模式出来
2010-08-13 14:20 1475笔试面试题目搜 ... -
1、说说Hashtable和HashMap的区别
2010-08-13 11:09 1199笔试面试题目搜集整理【每日增加】 1、说说Hasht ...
相关推荐
### Struts2与Struts1的主要区别 #### Struts2架构设计与实现方式 - **Struts2**在设计上采用了更加灵活的方式,每个请求都对应一个实例化的Action对象,而不是像**Struts1**那样在整个请求周期内共享同一个Action...
再来说说JavaScript验证。在前端,为了提供更好的用户体验,我们通常会在客户端先进行一些基本的验证,如检查输入是否为空,长度是否符合要求等。JavaScript可以轻松实现这一点,通过添加事件监听器到登录表单的提交...
Struts2是一个强大的Java web框架,它为开发者提供了一种优雅的方式来组织和构建应用程序。拦截器是Struts2框架的核心特性之一,它们扮演着类似中间件的角色,可以在动作执行前后执行一些预处理或后处理任务。自定义...
Struts2、Spring和Hibernate应用实例,传说中的ssh不过如此,编程其实很简单,别被陌生的名词吓到~
Struts则负责接收用户的HTTP请求,比如发布新说说或评论的操作,然后将这些请求转发到相应的控制器处理。控制器会调用业务逻辑层(通常在Spring Bean中实现)进行处理,如验证用户权限,生成新的说说记录等,并最终...
在文件名“spring01inclass”和“sshchap04_inclass”中,“01”可能是章节编号,暗示了文章可能逐步讲解Spring框架,而“sshchap04”可能指的是SSH(Struts + Spring + Hibernate)集成开发中的第四章内容,这可能...
这里说说我的翻页功能,也许大家都没这样一做过。 达到的效果是显示当前页的前5页和后5页,第一页和最后页. 如下, <br>实现后,在每一个需要翻页的地方 就可以了。 <br>不需要在做别的操作,...
再来说说tabs组件。EasyUI的Tabs组件用于创建选项卡式界面,它可以将多个内容面板组织到不同的标签页中,提高页面的可读性和用户体验。每个标签页可以包含HTML内容、IFrame或者与其他EasyUI组件结合使用,如表格、...
当Web应用程序采用了Struts框架后,在Web应用启动时,Struts框架会初始化并加载配置文件`struts-config.xml`。这个配置文件定义了整个应用的结构,包括各个Action、Form Bean以及它们之间的映射关系。初始化完成后,...
再来说说`MySQL`,这是一个广泛使用的开源关系型数据库管理系统,具有高性能、高可靠性以及易于管理的特点。在这个例子中,数据库文件是项目的一部分,存储了与查询相关的表结构和数据。MySQL的使用包括创建数据库、...
再来说说Hibernate,它的配置文件通常是hibernate.cfg.xml。为了在编写时有代码提示,你需要确保Eclipse已经安装了Hibernate的插件,如Hibernate Tools。这个插件不仅可以提供配置文件的提示,还能帮助你生成数据库...
通过以上步骤,我们便能构建一个基本的JAVA SSH论坛系统,提供用户注册、登录、发布说说、评论等功能,满足用户间的交流需求。这个过程涉及了Java Web开发的多个核心技术,对提升开发者的技术栈和项目经验有着极大的...
13、谈谈Hashtable与HashMap,区别等 14、谈谈JNI, 15、还有一个问题,说说ajax的执行原理 16、java的内存回收机制,是否可以人工干预 17、描述一下你做过的你觉得印象较深刻的项目。 18、说一下集合框架有什么...
13.Struts在你以前项目中有无用到过,说说Struts流程和你在项目中用Struts来做什么功能 14.索引你知道吗?索引有哪些优缺点?你做项目的时候,知道那些SQL语句会触发索引? 15.向一张表中如何插入一组数据? 16....
再来说说MyBatis,它是一个优秀的持久层框架,将SQL语句与Java代码分离,避免了传统的DAO层繁琐的编写工作。MyBatis允许开发者自定义SQL,存储过程,甚至能根据条件动态生成SQL,提高了数据库操作的灵活性。它通过...
"simple项目"是一个基于Java开发的项目,其中包含了两个关键的框架依赖:Struts2和Hibernate。Struts2是Java Web开发中广泛使用的MVC框架,它提供了强大的控制层功能,帮助开发者构建可维护、可扩展的Web应用程序。...
72.2. STRUTS的应用(如STRUTS架构) 66 72.3. 请写出Struts的工作原理、工作机制 67 72.4. struts的处理流程。 67 72.5. Struts 2框架的大致处理流程如下: 68 72.6. Struts体系结构中的组件 69 72.7. struts如何实现...
8、说说struts1与struts2的区别。 121 9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 122 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 122 11、...
再来说说Web开发框架的驱动,这里提到了Struts2。Struts2是一个流行的Java Web框架,它的驱动通常指的是与其兼容的持久层框架或插件,如Hibernate或MyBatis。这些驱动或插件帮助开发者更高效地进行数据库操作,减少...
再来说说视图解析器(ViewResolver)。它的作用是将处理器返回的逻辑视图名转换为实际的视图。例如,我们可以使用InternalResourceViewResolver,配置前缀和后缀,使得逻辑视图名如"index"能对应到实际的JSP页面"WEB...