zoukankan      html  css  js  c++  java
  • Struts2中ModelDriven的使用

    它是Struts2种独有的一种接收用户输入的机制,想在项目中使用模型驱动

    (ModelDriven)需要让Action实现com.opensymphony.xwork2.ModelDriven 接口,使用它

    的getModel()方法来通知Struts2要注入的属性类型,并且声明属性时一定要实例化,但不需get,

    set方法。

        package com.lsc.alan.action;  
          
        import com.lsc.alan.vo.User;  
        import com.opensymphony.xwork2.ModelDriven;  
        /** 
         * 使用模型驱动来接受用户输入,需要实现ModelDriven接口 
         * @author Alan 
         * 时间:2009年7月10日 
         */  
        public class LoginAction3 implements ModelDriven<User>{  
            /** 领域模型User对象 **/  
            private User user = new User();  
              
            public User getModel() {  
                return user;  
            }  
            public String execute(){  
                if (user.getUsername().equals("Alan") && user.getPassword().equals("Alan")){  
                    return "success";  
                } else {  
                    return "failure";  
                }  
            }  
        }  
    


  • 相关阅读:
    「CodeForces
    「POJ
    「CodeForces
    「CodeForces
    【CodeForces 717C】Potions Homework
    【CodeForces 730H】Car Repair Shop
    【CodeForces 730H】Delete Them
    【Gym 100947I】What a Mess
    j
    PDE工具箱的简单使用
  • 原文地址:https://www.cnblogs.com/riasky/p/3507295.html
Copyright © 2011-2022 走看看