首页>代码>s2sh开发java web学生成绩管理系统myeclipse+mysql>/学生成绩管理系统2/学生成绩管理系统源代码/ssh/src/com/ssh/action/LoginAction.java
package com.ssh.action; import javax.annotation.Resource; import org.apache.struts2.ServletActionContext; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import com.opensymphony.xwork2.ActionSupport; import com.ssh.model.Admin; import com.ssh.model.Student; import com.ssh.model.Teacher; import com.ssh.service.LoginService; /** * 登录验证控制类:包括学生、教师、管理员的登录验证 * */ @Component("loginAction") @Scope("prototype") public class LoginAction extends ActionSupport { private static final long serialVersionUID = 1L; private int type; private String username; private String password; private Student student; private Teacher teacher; private Admin admin; private LoginService loginService; public LoginService getLoginService() { return loginService; } @Resource public void setLoginService(LoginService loginService) { this.loginService = loginService; } public int getType() { return type; } public void setType(int type) { this.type = type; } 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 Student getStudent() { return student; } public void setStudent(Student student) { this.student = student; } public Teacher getTeacher() { return teacher; } public void setTeacher(Teacher teacher) { this.teacher = teacher; } /** * 学生、教师、管理员登录验证 */ @Override public String execute() throws Exception { System.out.println("username=" + username); System.out.println("password=" + password); System.out.println("type=" + type); if (type == 0) {// 学生登录验证 //int id = Integer.parseInt(username); student = loginService.checkStudentLogin(username, password); if (student != null) { ServletActionContext.getRequest().getSession().setAttribute( "student", student); return "student"; } else return INPUT; } else if (type == 1) {// 教师登录验证 //int id = Integer.parseInt(username); teacher = loginService.checkTeacherLogin(username, password); if (teacher != null) { ServletActionContext.getRequest().getSession().setAttribute( "teacher", teacher); return "teacher"; } else return INPUT; } else {// 管理员登录验证 admin = loginService.checkAdminLogin(username, password); if (admin != null) { ServletActionContext.getRequest().getSession().setAttribute( "admin", admin); return "admin"; } else return INPUT; } } }
最近下载更多
3090754224 LV2
1月7日
gzist111 LV1
2023年11月30日
hxfzooz LV2
2023年7月11日
zhouye123 LV1
2023年6月27日
ziv5466123 LV7
2023年6月18日
baowanhong LV2
2023年6月10日
qiangmin1223 LV11
2023年4月24日
zmhhhhhh LV4
2023年3月7日
liurun LV1
2022年12月30日
asder1348 LV1
2022年12月27日