- 浏览: 516078 次
- 性别:
- 来自: 北京
-
文章分类
- 全部博客 (672)
- 随便写写 (3)
- javascript (16)
- Java exam (58)
- JSP exam (25)
- Servlet exam (25)
- Struts exam (24)
- Spring exam (24)
- Hibernate exam (19)
- EJB exam (25)
- SOA exam (6)
- AJAX exam (25)
- Web开发 exam (25)
- 软件工程 exam (25)
- 项目管理 exam (25)
- .NET exam (23)
- ASP.NET exam (24)
- C# exam (24)
- C++ exam (25)
- C语言 exam (13)
- ASP exam (0)
- PHP exam (0)
- Ruby exam (0)
- Python exam (0)
- Delphi exam (0)
- Linux exam (0)
- UNIX exam (25)
- 数据库 exam (24)
- Oracle exam (25)
- SQL Server exam (20)
- MySQL exam (16)
- Mobile开发 exam (10)
- 嵌入式开发 exam (6)
- 网络安全 exam (0)
- 网络技术 exam (0)
- 综合技术 exam (0)
- HR面试 exam (0)
- 英语面试 exam (0)
- 外企面试 exam (0)
- 软件测试 exam (0)
- QTP exam (0)
- LoadRunner exam (0)
- 网友面经 exam (0)
- 应届生 exam (0)
- 面试指导 exam (0)
- IQ测试 exam (0)
- Flex exam (2)
- uml-ea (1)
最新评论
-
dxking100:
远光没有笔式题的说..
最新远光软件笔试题面试题内容(1) -
heming_way:
谢谢,正在复习软件工程考试呢,呵呵
《软件工程》选择题 -
梅玲达:
可以更详细点吗?
Hibernate中Criteria 和DetachedCriteria的作用是什么? -
buptjian:
学习下,试试看,谢谢啊~
Prototype如何实现页面局部定时刷新? -
bubblegum89:
这个。。。和我笔试时候做的 感觉完全不一样
最新远光软件笔试题面试题内容(3)
Question: What is RequestProcessor and RequestDispatcher?
Answer: The controller is responsible for intercepting and translating user input into actions to be performed by the model. The controller is responsible for selecting the next view based on user input and the outcome of model operations. The Controller receives the request from the browser, invoke a business operation and coordinating the view to return to the client.
The controller is implemented by a java servlet, this servlet is centralized point of control for the web application. In struts framework the controller responsibilities are implemented by several different components like
The ActionServlet Class
The RequestProcessor Class
The Action Class
The ActionServlet extends the javax.servlet.http.httpServlet class. The ActionServlet class is not abstract and therefore can be used as a concrete controller by your application.
The controller is implemented by the ActionServlet class. All incoming requests are mapped to the central controller in the deployment descriptor as follows.
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
</servlet>
All request URIs with the pattern *.do are mapped to this servlet in the deployment descriptor as follows.
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.do</url-pattern>
A request URI that matches this pattern will have the following form.
http://www.my_site_name.com/mycontext/actionName.do
The preceding mapping is called extension mapping, however, you can also specify path mapping where a pattern ends with /* as shown below.
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/do/*</url-pattern>
<url-pattern>*.do</url-pattern>
A request URI that matches this pattern will have the following form.
http://www.my_site_name.com/mycontext/do/action_Name
The class org.apache.struts.action.requestProcessor process the request from the controller. You can sublass the RequestProcessor with your own version and modify how the request is processed.
Once the controller receives a client request, it delegates the handling of the request to a helper class. This helper knows how to execute the business operation associated with the requested action. In the Struts framework this helper class is descended of org.apache.struts.action.Action class. It acts as a bridge between a client-side user action and business operation. The Action class decouples the client request from the business model. This decoupling allows for more than one-to-one mapping between the user request and an action. The Action class also can perform other functions such as authorization, logging before invoking business operation. the Struts Action class contains several methods, but most important method is the execute() method.
public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception;
The execute() method is called by the controller when a request is received from a client. The controller creates an instance of the Action class if one doesn’t already exist. The strut framework will create only a single instance of each Action class in your application.
Action are mapped in the struts configuration file and this configuration is loaded into memory at startup and made available to the framework at runtime. Each Action element is represented in memory by an instance of the org.apache.struts.action.ActionMapping class . The ActionMapping object contains a path attribute that is matched against a portion of the URI of the incoming request.
<action>
path= “/somerequest”
type=”com.somepackage.someAction”
scope=”request”
name=”someForm”
validate=”true”
input=”somejsp.jsp”
<forward name=”Success” path=”/action/xys” redirect=”true”/>
<forward name=”Failure” path=”/somejsp.jsp” redirect=”true”/>
</action>
Once this is done the controller should determine which view to return to the client. The execute method signature in Action class has a return type org.apache.struts.action.ActionForward class. The ActionForward class represents a destination to which the controller may send control once an action has completed. Instead of specifying an actual JSP page in the code, you can declaratively associate as action forward through out the application. The action forward are specified in the configuration file.
<action>
path= “/somerequest”
type=”com.somepackage.someAction”
scope=”request”
name=”someForm”
validate=”true”
input=”somejsp.jsp”
<forward name=”Success” path=”/action/xys” redirect=”true”/>
<forward name=”Failure” path=”/somejsp.jsp” redirect=”true”/>
</action>
The action forward mappings also can be specified in a global section, independent of any specific action mapping.
<global-forwards>
<forward name=”Success” path=”/action/somejsp.jsp” />
<forward name=”Failure” path=”/someotherjsp.jsp” />
</global-forwards>
public interface RequestDispatcher
Defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server. The servlet container creates the RequestDispatcher object, which is used as a wrapper around a server resource located at a particular path or given by a particular name.
This interface is intended to wrap servlets, but a servlet container can create RequestDispatcher objects to wrap any type of resource.
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(java.lang.String path)
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response. The resource can be dynamic or static.
The pathname must begin with a “/” and is interpreted as relative to the current context root. Use getContext to obtain a RequestDispatcher for resources in foreign contexts. This method returns null if the ServletContext cannot return a RequestDispatcher.
Parameters:
path - a String specifying the pathname to the resource
Returns:
a RequestDispatcher object that acts as a wrapper for the resource at the specified path
See Also:
RequestDispatcher, getContext(java.lang.String)
getNamedDispatcher
public RequestDispatcher getNamedDispatcher(java.lang.String name)
Returns a RequestDispatcher object that acts as a wrapper for the named servlet.
Servlets (and JSP pages also) may be given names via server administration or via a web application deployment descriptor. A servlet instance can determine its name using ServletConfig.getServletName().
This method returns null if the ServletContext cannot return a RequestDispatcher for any reason.
Parameters:
name - a String specifying the name of a servlet to wrap
Returns:
a RequestDispatcher object that acts as a wrapper for the named servlet
See Also:
RequestDispatcher, getContext(java.lang.String), ServletConfig.getServletName()
Answer: The controller is responsible for intercepting and translating user input into actions to be performed by the model. The controller is responsible for selecting the next view based on user input and the outcome of model operations. The Controller receives the request from the browser, invoke a business operation and coordinating the view to return to the client.
The controller is implemented by a java servlet, this servlet is centralized point of control for the web application. In struts framework the controller responsibilities are implemented by several different components like
The ActionServlet Class
The RequestProcessor Class
The Action Class
The ActionServlet extends the javax.servlet.http.httpServlet class. The ActionServlet class is not abstract and therefore can be used as a concrete controller by your application.
The controller is implemented by the ActionServlet class. All incoming requests are mapped to the central controller in the deployment descriptor as follows.
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
</servlet>
All request URIs with the pattern *.do are mapped to this servlet in the deployment descriptor as follows.
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.do</url-pattern>
A request URI that matches this pattern will have the following form.
http://www.my_site_name.com/mycontext/actionName.do
The preceding mapping is called extension mapping, however, you can also specify path mapping where a pattern ends with /* as shown below.
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/do/*</url-pattern>
<url-pattern>*.do</url-pattern>
A request URI that matches this pattern will have the following form.
http://www.my_site_name.com/mycontext/do/action_Name
The class org.apache.struts.action.requestProcessor process the request from the controller. You can sublass the RequestProcessor with your own version and modify how the request is processed.
Once the controller receives a client request, it delegates the handling of the request to a helper class. This helper knows how to execute the business operation associated with the requested action. In the Struts framework this helper class is descended of org.apache.struts.action.Action class. It acts as a bridge between a client-side user action and business operation. The Action class decouples the client request from the business model. This decoupling allows for more than one-to-one mapping between the user request and an action. The Action class also can perform other functions such as authorization, logging before invoking business operation. the Struts Action class contains several methods, but most important method is the execute() method.
public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception;
The execute() method is called by the controller when a request is received from a client. The controller creates an instance of the Action class if one doesn’t already exist. The strut framework will create only a single instance of each Action class in your application.
Action are mapped in the struts configuration file and this configuration is loaded into memory at startup and made available to the framework at runtime. Each Action element is represented in memory by an instance of the org.apache.struts.action.ActionMapping class . The ActionMapping object contains a path attribute that is matched against a portion of the URI of the incoming request.
<action>
path= “/somerequest”
type=”com.somepackage.someAction”
scope=”request”
name=”someForm”
validate=”true”
input=”somejsp.jsp”
<forward name=”Success” path=”/action/xys” redirect=”true”/>
<forward name=”Failure” path=”/somejsp.jsp” redirect=”true”/>
</action>
Once this is done the controller should determine which view to return to the client. The execute method signature in Action class has a return type org.apache.struts.action.ActionForward class. The ActionForward class represents a destination to which the controller may send control once an action has completed. Instead of specifying an actual JSP page in the code, you can declaratively associate as action forward through out the application. The action forward are specified in the configuration file.
<action>
path= “/somerequest”
type=”com.somepackage.someAction”
scope=”request”
name=”someForm”
validate=”true”
input=”somejsp.jsp”
<forward name=”Success” path=”/action/xys” redirect=”true”/>
<forward name=”Failure” path=”/somejsp.jsp” redirect=”true”/>
</action>
The action forward mappings also can be specified in a global section, independent of any specific action mapping.
<global-forwards>
<forward name=”Success” path=”/action/somejsp.jsp” />
<forward name=”Failure” path=”/someotherjsp.jsp” />
</global-forwards>
public interface RequestDispatcher
Defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server. The servlet container creates the RequestDispatcher object, which is used as a wrapper around a server resource located at a particular path or given by a particular name.
This interface is intended to wrap servlets, but a servlet container can create RequestDispatcher objects to wrap any type of resource.
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(java.lang.String path)
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response. The resource can be dynamic or static.
The pathname must begin with a “/” and is interpreted as relative to the current context root. Use getContext to obtain a RequestDispatcher for resources in foreign contexts. This method returns null if the ServletContext cannot return a RequestDispatcher.
Parameters:
path - a String specifying the pathname to the resource
Returns:
a RequestDispatcher object that acts as a wrapper for the resource at the specified path
See Also:
RequestDispatcher, getContext(java.lang.String)
getNamedDispatcher
public RequestDispatcher getNamedDispatcher(java.lang.String name)
Returns a RequestDispatcher object that acts as a wrapper for the named servlet.
Servlets (and JSP pages also) may be given names via server administration or via a web application deployment descriptor. A servlet instance can determine its name using ServletConfig.getServletName().
This method returns null if the ServletContext cannot return a RequestDispatcher for any reason.
Parameters:
name - a String specifying the name of a servlet to wrap
Returns:
a RequestDispatcher object that acts as a wrapper for the named servlet
See Also:
RequestDispatcher, getContext(java.lang.String), ServletConfig.getServletName()
发表评论
-
一组Struts的选择测试题附答案(1)
2010-08-12 16:34 373(1)在Struts应用的视图中包含哪些组件?(多选)选项:( ... -
如何在struts中配置数据源在,什么文件?用什么标签?如何取出DataSource?
2010-08-12 16:34 746Struts-config.xml<data-sourc ... -
Struts中最核心的类和包有哪些?
2010-08-12 16:34 6221. org.apache.struts.action基本上, ... -
Difference between Chain and Redirect Action result types
2010-08-12 16:34 377Chain result type is used for A ... -
如何提高Struts2的性能?
2010-08-12 16:34 6251. 关闭logging和开发模式(devMode), dev ... -
Spring和Struts的区别?
2010-08-12 16:34 732strusts:是一种基于MVC模式的一个web层的处理。Sp ... -
struts+spring面试题
2010-08-12 16:34 6871.strutsAction是不是线程安全的?如果不是,有什么 ... -
Struts中如何基于validation.xml来启用客户端验证?
2010-08-12 16:34 398可以使用<html:javascript>标签来进 ... -
国外的一些struts面试题(4)
2010-08-12 16:34 398Question: Can I setup Apache St ... -
介绍一下Struts的ActionServlet类
2010-08-12 16:34 764ActionServlet继承自javax.servlet.h ... -
Struts,Spring,Hibernate面试题总结
2010-08-12 16:34 414转载地址:http://blog.csdn.net/David ... -
一组Struts的选择测试题附答案(2)
2010-08-12 16:34 450(1)假设在helloapp应用中有一个hello.jsp,它 ... -
如何用Struts实现国际化?
2010-08-12 16:34 926国际化:不用修改代码,就适用于不同的语言国家本地化:如果要适应 ... -
介绍一下Struts的Action类
2010-08-12 16:34 415ActionServlet把全部提交的请求都被控制器委托到Re ... -
如何配置spring+struts?
2010-08-12 16:34 466在struts-config.xml加入一个插件,通过它加载a ... -
Struts中DispatchAction和Action类有什么不同?
2010-08-12 16:34 767DispatchAction是Struts包含的另一个能大量节 ... -
Struts框架如何取得消息资源文件中的信息?
2010-08-12 16:34 723消息资源文件是一些简单的.properties文件,这些文件包 ... -
国外的一些struts面试题(1)
2010-08-12 16:34 675Q: What is ActionServlet?A: The ... -
国外的一些struts面试题(3)
2010-08-12 16:34 370Question: Why cant we overide c ... -
如何实现struts的validator框架?
2010-08-12 16:34 651手动: public class my ...
相关推荐
Struts2 面试题 Struts2 是基于 Java 语言的 Web 应用程序框架,继承自 WebWork 框架。Struts2 的主要特点是使用 FilterDispatcher 作为核心控制器,将请求分发到相应的 Action 中。下面是 Struts2 面试题中涉及到...
标题中提到的是“struts2面试题”,所以本文的知识点将围绕Struts2框架的面试常见问题展开,包括基础知识点、常用类和工作流程等。 首先,我们需要了解Struts2框架的基础概念。Struts2是一个用于创建企业级Java Web...
在深入探讨Struts面试题之前,我们首先理解Struts1的基本架构和工作原理。 **1. Struts1框架的核心组件:** - **ActionServlet**:这是Struts1的核心控制器,它是一个实现了Servlet接口的类。当用户发起HTTP请求时...
### Struts2面试题及答案解析 #### 一、Struts2框架执行流程与核心组件 **题目背景:** 在Struts2框架中,FilterDispatcher是核心组件之一,它负责处理用户请求,并调用相应的Action进行业务逻辑处理。相较于...
JAVA笔试面试资料JDBC HTTP、JSP、Servlet、Struts面试题汇总资料: 2014年最新Java笔试题及答案.docx 225道Java面试题 学会了Java面试随你问.docx Ant和Maven的作用是什么?...遇到的一些Java面试题回顾.docx
### Struts2基础面试题详解 #### 1. Struts2的核心控制器及其性质 - **Struts1的核心控制器**:在Struts1框架中,核心控制器是`ActionServlet`,这是一个实现了`HttpServlet`接口的类,因此本质上是一个Servlet。 ...
### Struts1与Struts2的关键区别及其工作流程详解 #### Struts1关键组件与工作流程 **核心组件:** - **ActionServlet:** Struts1的核心控制器,它负责接收HTTP请求,并将其转发到相应的Action。 - **...
持续更新ing Struts2 框架面试题汇总。 Struts2 基于 MVC 架构,框架结构清晰,使用 OGNL,提供了全局范围、包范围和Action范围的国际化资源文件管理实现。
以上就是关于Struts1面试题的一些核心知识点,包括其初始化流程、处理用户请求的步骤、数据验证机制以及配置文件中的元素详解。这些内容涵盖了Struts1的基本架构和工作原理,对于理解和解答相关面试问题非常关键。
### Struts2面试题知识点详解 #### 一、Struts2的工作流程 1. **请求接收**:所有的请求首先会被`StrutsPrepareAndExecuteFilter`接收。 2. **请求识别**:`StrutsPrepareAndExecuteFilter`判断这个请求是否属于...
#### 二、Struts2框架中的绳子问题(武汉晨安科技笔试题) 题目描述了一个经典的面试问题:“如何通过燃烧两条不均匀的绳子来计算出15分钟的时间?”解答此题的关键在于理解绳子燃烧的速度不是均匀的这一前提。具体...
【Struts2面试题】 1. **Struts2架构**:基于MVC模式,了解Action、Result、Interceptor等核心组件。 2. **Struts2拦截器**:自定义拦截器,理解默认拦截器栈及其作用。 3. **Struts2配置**:struts.xml文件,...
以下是一些Struts面试题及相关的知识点解析: 1. **什么是Struts框架?** Struts是一个开源的MVC框架,它基于Model-View-Controller设计模式,旨在提高Java Web应用的可维护性和可扩展性。它提供了请求处理、页面...
根据给定的信息,我们将深入探讨Struts2框架中的一些核心概念,包括OGNL表达式的使用、ValueStack的理解及其数据存取方法,以及拦截器的生命周期等。 ### OGNL表达式及其三要素 #### OGNL简介 OGNL(Object-Graph ...
外企面试,软件测试面试题,Python面试题,Oracle面试题,MySql面试题,Web开发面试题,Unix面试题,程序员面试,网络技术面试题,网络安全面试题,Linux面试题,Hibernate面试题,Spring面试题,SQL Server面试题,Struts面试题,...
Struts 是一个开源的Java Web框架,由Apache软件基金会维护,主要用于构建企业级...以上是关于Struts基础的一些常见面试题和答案,深入理解和掌握这些概念对于Java Web开发者来说非常重要,尤其是在处理企业级应用时。
Spring、Struts2、Hibernate面试题详解 本文将详细解释 Spring、Struts2、Hibernate 面试题中的知识点,涵盖了 MVC 模式、Struts1.2 和 Struts2.0 的区别、单例模式、Servlet 依赖、可测试性、项目中使用 SSH 的...