浏览 1401 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-01-24
最后修改:2010-01-24
Id.java //Model的父类,为了该死的JSTL我得加上get/set public abstract class Id<T extends Id<T>> { @EncDec public long id; public long id() { return id; } @SuppressWarnings("unchecked") public T id(long id_) { id = id_; return (T)this; } public long getId() { return id; } public void setId(long id) { this.id = id; } } User.java //用户信息 public class User extends Id<User> { @EncDec public String name; @EncDec public int age; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } } DoUser.java //CRU操作,同时处理HTTP请求 public class DoUser extends Do { @Service @Transaction.Any //只是跳转用,没有数据操作 public String create_() throws Exception { return "/create"; } @Service public String create(String name, int age) throws Exception { User u = new User(); u.name = name; u.age = age; data.put(u); return "redirect:/"; } @Service @Transaction.Any public String update_(long id, ModelMap map) throws Exception { User u = data.get(User.class, id); map.put("user", u); return "/update"; } @Service public String update(long id, String name, int age) throws Exception { User u = new User().id(id); u.name = name; u.age = age; data.put(u); return "redirect:/"; } @Service public String get(long id, ModelMap map) throws Exception { User u = data.get(User.class, id); map.put("user", u); return "/index"; } } 页面代码就不贴了,全文完 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |