有关ModelDriven的使用原理,参见http://blog.csdn.net/li_tengfei/archive/2010/12/25/6098145.aspx
public class ContactAction extends ActionSupport implements ModelDriven<Contact> {
private static final long serialVersionUID = -2318419860549968641L;
private TextProvider textProvider;
private UserServices userServices;
private ContactServices contactServices;
private int cid;
private Contact contact = new Contact();
@SkipValidation
public String loadForUpdate() {
Contact acontact = contactServices.read(contact.getId());
BeanUtils.copyProperties(acontact, contact);
return Action.SUCCESS;
}
当进行编辑时,如果去掉loadForUpdate方法中的第二行语句,则进入到更新视图时,除了Id字段有值,其它字段都是控制,需要加上第二句话,将值栈中的对象换成最新的对象。
使用的BeanUtil是spring框架提供的,非apache。
分享到:
相关推荐
Struts2_ModelDriven接收参数(项目案例及视频) 初学者必备.
自己的总结 还很不全面希望对你您有用 主要是控制url
struts2中action实现ModelDriven后无法返回json的解决方法,需要的朋友可以参考一下
NULL 博文链接:https://diaochenlong2.iteye.com/blog/1829436
刚开始学struts2时,自己写的小工程。
ModelDriven用法 拦截器 struts2
11.1.2 Struts 2如何解决本地Java对i18n支持的问题 243 11.2 Struts 2 i18n示例 244 11.2.1 Struts 2 i18n快速展示 244 11.2.2 幕后一览 246 11.3 Struts 2 i18n详情 247 11.3.1 Struts 2默认的TextProvider Re-...
Struts2_Action学习笔记、通配符{1},{2}......
struts2的ModelDriven和Prepareable接口使用demo,包括显示数据,增加数据,删除数据和修改数据
2.struts2_2 validationl,ModelDriven,properties 3.struts2_interceptor 拦截器,自定义拦截器 4.struts2_log4j 5.struts2_spring struts spring 整合 以上功能包含完整示例代码 Eclipse Java EE IDE for Web ...
01 Struts2-Action 5 一、 Struts作用: 5 二、 搭建Struts2的运行环境: 5 三、 Namespace 6 四、 标签 6 五、 Action 6 六、 路径问题的说明 8 七、 Action的动态调用方法 8 八、 Action通配符(wildcard)的配置 9 ...
b.XXaction中该对象返回个给实现对象ModelDriven的泛型, 即action中下面方法 return的model 对象引用 public OperatingConditionsEntity getModel() { return model; } 2.加#号的放置获取,放置在制定域...
纯Struts2 struts-2.3.16.1版本下的demo,1、Struts2标签 2、Action 3、ActionSupport中validate 4、prepare 5、modeldriven 6、国际化 7、Token 8、拦截器
01 Struts2-Action 5 一、 Struts作用: 5 二、 搭建Struts2的运行环境: 5 三、 Namespace 6 四、 标签 6 五、 Action 6 六、 路径问题的说明 8 七、 Action的动态调用方法 8 八、 Action通配符(wildcard)的配置 9 ...
public class UserAction implements ModelDriven{ private User user = new User(); public User getModel() { return user; } public String getUsers(){ System.out.println(user.getUserName()); ...
IBM基于模型等项目开发ibm_modeldriven2
Spring4.0、Struts2.3.15、Hibernate4.2.4、jQuery1.9.1涉及到了诸多开发时的细节:ModelDriven、Preparable 拦截器、编写自定义的类型转换器、Struts2 处理 Ajax、OpenSessionInViewFilter、迫切左外连接、Spring ...
2.7.2 JSP中实现随机抽奖 2.8 疑难解惑 2.8.1 在JSP页面中编写中文之后不能保存 2.8.2 访问JSP页面出现乱码 2.8.3 在JSP页面中使用Include指令后,JSP不能编译 2.9 精彩回顾 第3章前人栽树后人乘凉 ——、JSP内置...
参考一下链接,修改了下,做了个例子 http://shiningwu.javaeye.com/blog/184117 差别在于action没有继承ModelDriven,并且把所有需要的jar包都打包了,实现了登陆,修改,删除,一览功能 工具为mysql + tomcat6