struts2中的域模型DTO接收参数

struts2中用dto域模型接收前台传来的参数,需实现ModelDriven<**>接口,并实现getModel()方法将dto具体实现对象返回

package bbs.action;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import bbs.model.User;
import bbs.service.UserManager;
import bbs.vo.UserVo;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Component("login")
@Scope("prototype")
public class LoginAction extends ActionSupport implements ModelDriven<UserVo> {

    private Map request;
    private Map session;
    private Map application;
    private UserManager userManager;
    private UserVo uservo = new UserVo();

    public LoginAction() {
        request = (Map) ActionContext.getContext().get("request");
        session = ActionContext.getContext().getSession();
        application = ActionContext.getContext().getApplication();
    }

    public UserVo getModel() {
        return uservo;

    }

    @Override
    public String execute() throws Exception {
        System.out.println(uservo.getUsername());
        return "success";
    }

    public UserManager getUserManager() {
        return userManager;
    }

    @Resource
    public void setUserManager(UserManager userManager) {
        this.userManager = userManager;
    }

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值