58,454
社区成员
发帖
与我相关
我的任务
分享
package com.action;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.dao.PatientinfoDAO;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.vo.PatientinfoDTO;
public class MyLoginAction02 extends ActionSupport {
private String Pname;
private String Ppassword;
private String psex;
public String getPsex() {
return psex;
}
public void setPsex(String psex) {
this.psex = psex;
}
static{ //用execute会执行,用method="changePsex"就不执行!!很烦恼 找不出问题
System.out.println("进来了!");
}
public String execute() throws Exception {
System.out.print(psex);//用execute会执行,用method="changePsex"就不执行!!很烦恼 找不出问题
PatientinfoDAO dao = new PatientinfoDAO();
String role = null;
PatientinfoDTO rs = new PatientinfoDTO();
rs = dao.findUserByAccountAndPassword(Pname, Ppassword);
if (rs != null) {
role = "patient";
Map session = ActionContext.getContext().getSession();
session.put("user", rs);
// System.out.print(patientLogin.get("name"));
session.put("role", role);
return "success01";
}
return "input";
}
public String changePsex() throws Exception {
System.out.print(psex);
PatientinfoDAO dao = new PatientinfoDAO();
int r = dao.updateSex(Pname, psex);
if (r > 0)
return SUCCESS;
else
return INPUT;
}
public String getPname() {
return Pname;
}
public void setPname(String pname) {
Pname = pname;
}
public String getPpassword() {
return Ppassword;
}
public void setPpassword(String ppassword) {
Ppassword = ppassword;
}
}