struts基本配置,在web.xml中
<servlet>
<servlet-name>
<servlet-class>org.apach.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/strutx-config.xml</param-value>
</init-param>
<servlet>
struts-config.xml基本配置信息:
<struts-config>
<data-sources />
<form-beans />
<global-exceptions />
<global-forwards />
<action-mappings>
<action path="/login"
type="com.xxx.LoginAction"
/>
</action-mappings>
<message-resources parameter="com.xxx.ApplicaionResources.properties" />
</struts-config>
------------
struts 执行步骤
1. 载入web.xml, 实例化ActionServlet
2. 执行到ActionServlet中的init方法, 将<init-param>里的名为config的值读出来,
这个值, 对应struts-config.xml的所在位置和文件名
3. 生成ActionMapping对象, 这个对象里放的都是struts-config.xml中的配置内容以键值 对的方式.
<action path="" type="" />
第一个对应是把<form action="login.do">和<action path="/login">
login.do -> login, path中,是不用写.do
如果对应不上, 出错
如果对应上, 把对应的struts-config.xml中的action段的内容读到ActionMapping对象 中.
经过这三步后,我们现在有三个东西,request, response, ActionMapping
4. 从ActionMapping中获得type的值,
5. 通过反射, 生成这个type值对应类的实例.
6. 调用对应的Action实例execute方法.
7. ActionServlet里还要收集这个Action的返回
<forward name="ok" path="/success.jsp" />
ActionMapping对象的findForward("xx")方法找到相应的forward
findForward方法返回的是一个ActionForward对象,把这个ActionForward对象
返回给ActionServlet
8. ActionServlet中解析出ActionForward对象里的地址, 并跳转.
<form-bean name="loginForm" type="" />
<action name="loginForm" type="" path="" />
<action xxx validate="true" input="/login.jsp" />
input表示如果没验证通过就跳转到哪去?
<action attribute="aaa" scope="request|session" />
request.get|setAttribute("aaa", new ActionForm);
findForward方法找寻的时候,首先找当前配置段中局部forward,如果找不到,再找全局的.
---------------------------------------
分享到:
- 2009-09-20 23:45
- 浏览 1032
- 评论(0)
- 论坛回复 / 浏览 (0 / 1222)
- 查看更多
相关推荐
我觉得struts1.2是一个比较稳定的框架,就连网上有名的教授都推荐用struts1.2,所以没有驱动的友友赶紧下载吧!
struts1.2 jar包 struts1.2 jar包 struts1.2 jar包 struts1.2 jar包 struts1.2 jar包
这是一个struts 1.2 + spring 2.5 + hibernate 3.2框架demo, 运行环境为eclipse 3.2 + tomcat 5.5 + oracle 11g
struts 1.2驱动包struts 1.2驱动包
struts1.2源码.rar 核心源码 struts-1.2.4-lib Struts1.2API chm格式
struts1.2-2.0学习总结
struts1.2标签实例超经典,方便大家学习,对初学者有很好帮助
STRUTS1.2中文文档.rar,里边包含很多的STRUTS1.2相关文档,认真的看看,你会有收获的
struts 1.2 标签使用说明,简单介绍了struts1.2的标签使用
struts1.2 简单文件上传例子(用eclipse3.4打开运行即可)
Struts1.2中文学习手册 初学者可以下载 不解释
用于struts1.2学习资料,用于查询时用的
jsp中 struts1.2 包 asdasdasd dasd a
struts1.2项目指导struts spring hibernate
struts1.2拦截器使用插件
struts1.2 商城购物 随意写的
struts1.2框架技术的基本原理及其组件的用法
struts1.2+spring2.0 登录 例子
次资源中包含了本人根据学习struts、struts1.2java框架总结出来的学习笔记,以及对这两个版本异同的比较,包含框架的从入门到精通,适合各种不同阶段的人员学习......
ext+struts1.2图书管理系统让你了解ext框架以及与struts1.2的整合