@Controller("loginAction") @Scope("prototype") @Resource(name="loginService")

package com.tfy.oa.action;


import javax.annotation.Resource;


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


import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.tfy.oa.Util.OAUtils;
import com.tfy.oa.dao.LoginDao;
import com.tfy.oa.dao.UserDao;
import com.tfy.oa.dao.impl.UserDaoImpl;
import com.tfy.oa.domain.User;
import com.tfy.oa.service.LoginService;
import com.tfy.oa.service.UserService;


@SuppressWarnings("serial")
@Controller("loginAction")
@Scope("prototype")
public class LoginAction extends ActionSupport implements ModelDriven<User>{
@Resource(name="loginService")
private LoginService loginService;


private UserDao udao = (UserDaoImpl) new UserDaoImpl();
private User model=new User();//放到栈顶
private UserService userService;
// private String username;
// private String password;


public String login() {
System.out.println("LoginAction  tfy home()");


// User u = userService.findUser(model);
System.out.println("this.getModel().getUsername()=="+this.getModel().getUsername());
System.out.println("this.getModel().getPassword())=="+this.getModel().getPassword());
User user=this.loginService.login(this.getModel().getUsername(),this.getModel().getPassword());

/*if (u != null) {
return SUCCESS;
}
return "input";*/
if(user==null){
//用户名和密码错误
//在登陆页面显示错误信息
return "input";
}else{
OAUtils.putUserToSession(user);
return "index";
}
}








public UserService getUserService() {
return userService;
}








public void setUserService(UserService userService) {
this.userService = userService;
}






/*
public String getUsername() {
return username;
}


public void setUsername(String username) {
this.username = username;
}


public String getPassword() {
return password;
}


public void setPassword(String password) {
this.password = password;
}
*/






public User getModel() {
return this.model;
}







}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值