实现过程:

Web容器收到 请求(HttpServletRequest)它将请求传递给一个标准的的过滤链包括
(ActionContextCleanUp)过滤器,然后经过Other filters(SiteMesh ,etc),接下来需要调用FilterDispatcher核心控制器,然后它调用ActionMapper确定请求哪个Action,ActionMapper返回一个收集Action详细信息的ActionMaping对象。
接下来FilterDispatcher将控制权委派给ActionProxy,ActionProxy调用配置管理器(ConfigurationManager) 从配置文件中读取配置信息(struts.xml),然后创建ActionInvocation对象,ActionInvocation在调用Action之前会依次的调用所用配置拦截器(Interceptor N) 一旦执行结果返回结果字符串ActionInvocation负责查找结果字符串对应的(Result)然后执行这个Result Result会调用一些模版(JSP)来呈现页面,之后拦截器(Interceptor N)会再被执行(顺序和Action执行之前相反)最后响应(HttpServletResponse)被返回在web.xml中配置的那些过滤器和(核心控制器)(FilterDispatcher)。
 
 
action类:
描述业务逻辑,其中execute()方法返回一个字符串值,如sucess
struts.xml  :将所有东西如jsp  action 等连在一起。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="user" namespace="/User" extends="struts-default">
<action name="Login">
<result>/login.jsp</result>
</action>
<action name="Welcome" class="com.yiibai.user.action.WelcomeUserAction">
<result name="SUCCESS">/welcome_user.jsp</result>
</action>
</package>
</struts>
web.xml:配置Web应用程序部署描述符(web.xml)文件Struts2的集成到Web项目
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping></web-app>
 
 

struts2 实现过程和xml配置的更多相关文章

  1. 【Struts2学习笔记(11)】对action的输入校验和XML配置方式实现对action的全部方法进行输入校验

    在struts2中,我们能够实现对action的全部方法进行校验或者对action的指定方法进行校验. 对于输入校验struts2提供了两种实现方法: 1. 採用手工编写代码实现. 2. 基于XML配 ...

  2. Struts2 XML配置详解

    struts官网下载地址:http://struts.apache.org/   1.    深入Struts2的配置文件 本部分主要介绍struts.xml的常用配置. 1.1.    包配置: S ...

  3. struts2视频学习笔记 22-23(基于XML配置方式实现对action的所有方法及部分方法进行校验)

    课时22 基于XML配置方式实现对action的所有方法进行校验   使用基于XML配置方式实现输入校验时,Action也需要继承ActionSupport,并且提供校验文件,校验文件和action类 ...

  4. Struts2笔记——struts.xml配置详解

    访问HelloWorld应用的路径的设置 * 在struts1中,通过<action path=“/primer/helloWorldAction.action”>节点的path属性指定访 ...

  5. struts2 的struts.xml配置详解

    在应用struts框架进行开发时,必不可少的一步就是对struts.xml进行配置,对于该文件了解越多,我们开发起一应用程序定会更加顺手.下面我们看一下struts.xml的内容,每一项都有什么作用. ...

  6. struts2拦截器-自定义拦截器,放行某些方法(web.xml配置)

    一.web.xml配置 <filter> <filter-name>encodingFilter</filter-name> <filter-class> ...

  7. struts2.1.6教程二、struts.xml配置及例程

    1.配置文件的优先级 在struts2中一些配置(比如常量)可以同时在struts-default.xml(只读性),strtus-plguin.xml(只读性),struts.xml,struts. ...

  8. Struts2第十篇【数据校验、代码方式、XML配置方式、错误信息返回样式】

    回顾以前的数据校验 使用一个FormBean对象来封装着web端来过来的数据 维护一个Map集合保存着错误信息-对各个字段进行逻辑判断 //表单提交过来的数据全都是String类型的,birthday ...

  9. struts2 --xml配置

    struts2.5 官方文档介绍 这个是struts2.5给出的web.xml配置方式,核心包已经被挪到了ng的上一层 <web-app id="MyStrutsApp" v ...

随机推荐

  1. SQL Server类型与C#类型对应关系

    SQL类型 C#类型 bit bool tinyint byte smallint short int int bigint long real float float double money de ...

  2. 用excel做一幅像素画

    开发背景 看到网上有人发教程,如何通过在excel里设置单元格颜色画一幅画,感觉手工做太复杂,就打算用程序实现一个. 开发运行环境 python 2.7 PIL xlsxwriter 用法 pytho ...

  3. Tree 使用方式

    Traditional Ways of Tree Traversal This page contains examples of some “standard” traversal algorith ...

  4. js页面加载进度条

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. [C入门 - 游戏编程系列] 贪吃蛇篇(六) - 蛇实现

    这一篇是关于设置蛇的属性的,接上一篇(五). 设置蛇的速度,很简单,只要不是负数就行了. void SNK_SetSnakeSpeed(Snake *snake, int speed) { ) sna ...

  6. java 将GBK编码文件转为UTF-8编码

    需要commons-io-2.0.1.jar public class Test { public static void main(String args[]) throws IOException ...

  7. 那两年炼就的Android内功修养

    http://blog.csdn.net/luoshengyang/article/details/8923485 http://iconsparadise.com/ http://blog.csdn ...

  8. EBS收单方/收货方

    select rt.name, hcas.org_id from ar.hz_cust_acct_sites_all hcas, ar.hz_cust_site_uses_all hcsu, ra_t ...

  9. poj1552

    Doubles Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18824   Accepted: 10846 Descrip ...

  10. 第17讲- UI常用组件之ImageView图片浏览

    第17讲 UI常用组件之ImageView图片浏览 二.图片浏览ImageView ImageView就是一个用来显示图片的视图: ImageView常见属性 常见属性 对应方法 说明 android ...