在Action 中读取页面传递来的数据
来源:互联网 发布:网络知识培训手机 编辑:程序博客网 时间:2024/04/30 13:55
在action获取页面数据有两种方式
1 属性驱动
为属性设置get 和set方法
2 模型驱动
模型驱动中的action 必须实现ModelDriven
在模型驱动的通过getModel方法将 将数据接收对象放置到栈顶进行接收数据
age com.wuyihuai.oa.struts2.action;import java.util.List;import org.apache.struts2.ServletActionContext;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionSupport;import com.opensymphony.xwork2.ModelDriven;import com.wuyihuai.ao.struts2.action.base.BaseAction;import com.wuyihuai.oa.domain.Department;import com.wuyihuai.oa.service.DepartmentService;public class DepartmentAction extends BaseAction implements ModelDriven<Department>{ private DepartmentService departmentService; private Department model=new Department(); //ModelDriven拦截器将model对象放置到栈顶接收数据 @Override public Department getModel() { // TODO Auto-generated method stub return this.model; } public DepartmentService getDepartmentService() {return departmentService;}public void setDepartmentService(DepartmentService departmentService) {this.departmentService = departmentService;} public String add(){ /** * 增加逻辑 * 1. 获取页面数据 * 属性驱动 * 属性和set 。get 方法 * * 模型驱动 * 这个action必须实现ModelDriven * 建立一个私有的模型对象 * 在这个action中有一个getModel方法 * 2. 把数据封装到javabean中 */
//重新定义department 而不直接是由this.getModel进行保存是为了 避免直接操作session而出错 Department department=new Department(); department.setDname(this.getModel().getDname()); department.setDescription(this.getModel().getDescription()); this.departmentService.saveDepartment(department); return null; }
0 0
- 在Action 中读取页面传递来的数据
- 在jsp页面中取action传递值的方法
- 在jsp页面中使用list列表来传递信息到action
- Struts2框架中action无法获取到jsp页面传递的表单数据的解决办法
- ssh 中 jquery ajax 调用action返回的json数据并传递到页面
- 在juqery的ajax和struts2整合开发时,对象数据的从页面到Action的传递问题
- struts中在两个action之间进行传递数据的方法
- struts中在两个action之间进行传递数据的方法
- android中通过实现Parcelable来在两个页面之间传递对象的简单使用
- 在JSP页面中访问action类中数据
- valuestack,stackContext,ActionContext.之间的关系以及action的数据在页面中取得的方法
- Android页面中数据的传递
- 关于Action向页面传递数据,对传递属性JSON化的拦截。
- android intent和intent action大全 android intent和intent action大全 android 中intent是经常要用到的。不管是页面牵转,还是传递数据
- 我想在工作流中使用XML来传递数据....
- 使用Bundle在Activity中来传递数据
- struts页面对象向action中传递
- 在Action中使用request接收Struts2传递的参数
- LeetCode 338. Counting Bits
- 14.LeetCode Longest Common Prefix(easy)[字符串公共前缀]
- 通俗易懂的机器学习入门指导
- Dubbo框架结构
- [线段树]讲义(1)
- 在Action 中读取页面传递来的数据
- 模糊聚类FCM的MATLAB实现
- CodeForces 200B Drinks
- 插入排序 java实现
- 黑马程序员——JAVA学习日志之多线程
- 01背包算法 动态规划(c++实现)
- poj-3041-Asteroids
- python调用caffe接口进行classify时提示Mean shape incompatible with input shape错误的解决方法
- android常见错误一