You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pyexr2f4a/action文件/GoLogin.java

101 lines
2.0 KiB

package com.action;
import com.dao.AdminDao;
import com.dao.StudentDao;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;
import javax.servlet.http.HttpSession;
public class GoLogin extends ActionSupport {
//??????Action????????????????????????
private String Type;
private String Username;
private String Password;
private String Msg;
private String check;
public String getCheck() {
return check;
}
public void setCheck(String check) {
this.check = check;
}
public String getType() {
return Type;
}
public void setType(String type) {
Type = type;
}
public String getUsername() {
return Username;
}
public void setUsername(String username) {
Username = username;
}
public String getPassword() {
return Password;
}
public void setPassword(String password) {
Password = password;
}
public String getMsg() {
return Msg;
}
public void setMsg(String msg) {
Msg = msg;
}
/**
* 以上就是获取输入登入信息的 * */
public String execute() throws Exception {
if(Type.equals("系统管理员"))
{
if (null == new AdminDao().CheckLogin(Username, Password)) {
Msg = "系统检查为空啊哈哈";
return INPUT;
}
else
{
//???ID
String Admin_ID=new AdminDao().CheckLogin(Username, Password);
//????session
HttpSession session = ServletActionContext.getRequest().getSession();
session.setAttribute("id", Admin_ID);
session.setAttribute("type", "1");
return SUCCESS;
}
}
else if(Type.equals("学生"))
{
if (null == new StudentDao().CheckLogin(Username, Password)) {
Msg = "学生用户名或密码输入错误";
return INPUT;
}
else
{
//???ID
String Student_ID=new StudentDao().CheckLogin(Username, Password);
//????session
HttpSession session = ServletActionContext.getRequest().getSession();
session.setAttribute("id", Student_ID);
session.setAttribute("type", "3");
return SUCCESS;
}
}
else
{
Msg = "用户名或密码输入错误";
return INPUT;
}
}
}