struts2中action配置非execute方法method跳转失败,甚至进不了action
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;
}
}
...全文
相关推荐
struts2 action 配置方法 &&struts2的配置文件
struts2 action几乎完全吸收了xwork 的精华,近日学习struts 2,总结一下action的配制方法。struts2相关的配置文件有web.xml(必须的),struts.xml(必须的),struts.properties,struts-default.xml,velocity.properties,struts-default.vm。
Strutc 2中Action中的执行方法
本文档简单的介绍了action的几种执行方法,主要是以实例介绍
Struts2中validate数据校验的两种方法详解附Struts2常用校验器
主要介绍了Struts2中validate数据校验的两种方法及Struts2常用校验器,本文介绍的非常详细,具有参考借鉴价值,感兴趣的朋友一起看看吧
Struts2开发 基本配置与类型转换
本篇文章,小编将为大家介绍关于Struts2开发 基本配置与类型转换,有需要的朋友可以参考一下
Struts2 入门概述(附图)
java struts2 Struts2 入门概述(附图)


Eclipse
