首页>代码>ssh整合extjs的项目实例>/TabpanelProject/src/com/inspur/action/UserAction.java
package com.inspur.action;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.json.annotations.JSON;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.inspur.model.User;
import com.inspur.service.UserService;
import com.opensymphony.xwork2.ActionSupport;

@Component("userAction")
@Scope("prototype")
public class UserAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private boolean success;
	private String message;
	private String randCode;
	private User user;

	private UserService userService;

	public String userLogin() {
		HttpSession session = ServletActionContext.getRequest().getSession();
		String randCode = (String) session.getAttribute("rand");
		boolean flag1 = randCode.trim().equals(this.getRandCode().trim()) ? true
				: false;
		boolean flag2 = userService.login(user);
		if (!flag1) {
			this.success = false;
			this.message = "你输入的验证码错误!";
		} else if (!(flag1 && flag2)) {
			this.success = false;
			this.message = "你输入的账号或密码错误!";
		} else {
			this.success = true;
			this.message = "登录成功!";
		}
		return SUCCESS;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	@JSON(serialize = false)
	public UserService getUserService() {
		return userService;
	}

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

	@JSON(serialize = false)
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getRandCode() {
		return randCode;
	}

	public void setRandCode(String randCode) {
		this.randCode = randCode;
	}

}
最近下载更多
lironggang  LV38 2022年8月8日
3106001395  LV1 2021年12月19日
wangzile1994  LV12 2020年3月26日
newnu88  LV12 2020年2月17日
何秀好  LV13 2019年11月19日
wacxin  LV10 2019年6月25日
yrfoogd  LV5 2019年6月21日
_stary  LV1 2019年5月31日
wknyhu  LV2 2019年1月14日
chikin333  LV11 2018年11月27日
最近浏览更多
chongminzheng  LV1 7月13日
WBelong  LV7 2023年12月11日
微信网友_6549826556514304  LV2 2023年7月6日
18103847055  LV7 2023年4月25日
haoyi198  LV3 2023年1月11日
uni-code_0123  LV1 2022年11月16日
唐老鸭  LV26 2022年6月23日
getset  LV8 2022年4月17日
3106001395  LV1 2021年12月19日
蛋黄派来的* 2021年12月7日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友