zoukankan      html  css  js  c++  java
  • action接受参数三种方法

    package com.lsp.action;
    
    import com.opensymphony.xwork2.ActionSupport;
    
    /**
     * ----------------这里是Action添加成员属性接受参数--------------
     */
    public class Action1 extends ActionSupport {
        private int id;
        private String name;
    
        public String test1() {
            System.out.println("name" + name);
            System.out.println("id" + id);
            return "test1";
        }
    
        public int getId() {
            return id;
        }
    
        public void setId(int id) {
            this.id = id;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    }
    =====================================================================================
    package com.lsp.action;
    
    import com.lsp.entity.User;
    import com.opensymphony.xwork2.ActionSupport;
    
    /**
     *利用对象域来进行传递和接受参数
     */
    public class Action2 extends ActionSupport {
        private User user;
    
        public String test2() {
            System.out.println("name=" + user.getName());
            System.out.println("id+" + user.getId());
            return "test2";
        }
    
        public User getUser() {
            return user;
        }
    
        public void setUser(User user) {
            this.user = user;
        }
    
    }
    =======================================================================
    
    
    package com.lsp.action;
    
    import com.lsp.entity.User;
    import com.opensymphony.xwork2.ActionSupport;
    import com.opensymphony.xwork2.ModelDriven;
    
    /**
     *域模型
     */
    public class Action3 extends ActionSupport implements ModelDriven<User> {
        private User user = new User();
    
        public String test3() {
            System.out.println("name=" + user.getName());
            System.out.println("id=" + user.getId());
            return "tset3";
        }
    
        @Override
        public User getModel() {
            // TODO Auto-generated method stub
            return user;
        }
    
    }

    可参考博客:http://www.cnblogs.com/bukudekong/archive/2012/03/29/2423064.html

     
  • 相关阅读:
    杭电1075
    杭电1016深度搜索问题
    杭电1015
    stringstream
    向量的点乘和叉乘
    杭电1010
    FCKEditor2.6.3 配置
    JQuery实现全选 与 批量删除
    JQuery实现下拉框的选择 与当CheckBox为服务器控件时如何获取值的操作,实现全选与删除
    JS 对GridView的一些操作
  • 原文地址:https://www.cnblogs.com/yunmengxiaohe/p/3914877.html
Copyright © 2011-2022 走看看