⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.java

📁 STRUTS2的入门 教程
💻 JAVA
字号:
package action;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.dao.LendDAO;
import com.dao.UserDAO;
import com.opensymphony.xwork2.ActionSupport;
import com.vo.MatureBook;
/**
 * 
 * 登录验证action
 *
 */
public class Login extends ActionSupport {
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		if (isInvalid(username) || isInvalid(password)) {
			msg = "用户名或者密码不能为空";
			return INPUT;
		}
		if (null == new UserDAO().checkAccount(username, password)) {
			msg = "用户名或者密码错误";
			return INPUT;
		}
		String userid = new UserDAO().checkAccount(username, password);
		HttpSession session = ServletActionContext.getRequest().getSession();
		session.setAttribute("userid", userid);
		list = new LendDAO().matureBook(Integer.parseInt(userid));
		return SUCCESS;
	}

	private boolean isInvalid(String value) {
		return (value == null || value.length() == 0);
	}

	private String msg = "您好";

	private String username;

	private String password;
	
	private List<MatureBook> list;

	public String getPassword() {
		return password;
	}

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

	public String getUsername() {
		return username;
	}

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

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public List<MatureBook> getList() {
		return list;
	}

	public void setList(List<MatureBook> list) {
		this.list = list;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -