Struts 2框架
来源:互联网 发布:男儿行 酒徒 知乎 编辑:程序博客网 时间:2024/05/17 08:52
@ActionForm
ActionForm的概念:ActionForm用于封装用户的请求参数,而请求参数是通过JSP页面的表单域传递过来的。
因此应保证ActionForm的参数,与表单域的名字相同。form表单的值就是封装在ActionForm对象里面。
ActionForm的作用机理:ActionForm本质上是一种javaBean,是专门用来传递表单数据的DTO(Data Transfer Object,数据传递对象)。
它包括用于表单数据验证的validate()方法和数据复位的reset()方法。
Struts框架利用ActionForm对象来临时存放视图页面中的表单数据。ActionForm有request和session俩种作用域(scope)。
如果ActionForm的作用域设定为request,ActionForm实例将保存在request对象中,像其他保存在request对象中的属性一样,仅在当前请求范围内有效。
如果ActionForm的作用域设定为session,那么ActionForm实例将被保存在session对象中,同一个ActionForm实例在整个HTTP会话中有效。
ActionForm配置:所有的ActionForm都被配置在struts-config.xml文件中,该文件包括了一个form-beans的元素。
该元素内定义了所有ActionForm,每个ActionForm对应一个form-bean元素。
struts的ActionForm共有俩种:静态form和动态form
静态form使用:
1、javaBean必须继承org.apache.struts.action.ActionForm类,并提供属性对应的get/set方法。
2、struts配置
<form-beans>
<form-bean name="userForm" type="com.struts1_study.bean.UserInfo">
</form-bean>
</form-beans>
<action path="/login"
type="com.struts1_study.action.login.UserManageAction"
name="userForm" parameter="method">
<forward name="input" path="/jsps/login/login.jsp"></forward>
<forward name="success" path="/jsps/login/welcome.jsp"></forward>
</action>
@Resource
注解的类路径/包:import javax.annotation.Resource; / annotation-api.jar
注意:如果用tomcat6的话,tomact6已经包含了jar包,不需要自己导入。不过不是的话,需要手动导入包。
例如:
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@Resource
protected AuthForm authForm;
@Resource
protected HttpServletRequest request;
@Execute
例如:
import org.seasar.struts.annotation.Execute;
@Execute(validator = false, input = "/master/auth.jsp")
public String moveAuthMaster() {
authMstService.getgroupComboList(authForm);
return "/master/auth.jsp";
}
- Struts 2框架配置
- Struts 2 框架教程
- Struts 2框架总结
- Struts 2框架
- Struts 2框架介绍
- struts与struts 2 框架浅析
- Struts Validation框架浅尝2
- Struts Validation框架浅尝2
- Struts Validation框架浅尝2
- Struts 2框架整合Spring
- Struts 2框架整合Spring
- Struts 2框架整合Spring
- Struts 2的校验框架
- Struts 2框架整合Spring
- Struts 2框架整合Spring
- Struts 2 REST 框架介绍
- WebMVC框架 之 Struts 2
- Struts 2 框架和配置
- 优化3D图形流水线
- blender game document 游戏引擎开发的建议
- Windows Rtl字符串相关接口源码
- asp.net mvc3.0安装失败解决方案
- 凸包模板
- Struts 2框架
- win7如何建立无线局域网
- Long Long、__int64使用总结
- Android resource notlong / long identifiers not working
- Linux下ps命令详解
- 在android模拟器上安装软件的方法
- ftok函数
- 用ScrollView 使TextView文字滚动并可修改滚动条和其背景颜色
- linux删出文件^M