日期:2014-05-19  浏览次数:20774 次

ssh:jsp页面调用action直接返回了success好像没有执行excute方法
jsp页面:
function denglu(){
if(form.username.value == "")
  {
  alert("用户名不能为空");
  form.username.focus();
  return false;
  }
  if(form.password.value == "")
  {
  alert("密码不能为空");
  form.password.focus();
  return false;
  }
  //alert("正在进入Action");
  form.action="<%=request.getContextPath()%>/userLoginAction.action";
form.submit();
struts.xml:
<action name="userLoginAction" class="com.Action.UserLoginAction">
  <result name="index">/JSP/index.jsp</result>
  <result name="admin_index">/JSP/admin_index.jsp</result>
  <result name="user_index">/JSP/user_index.jsp</result>
  <result name="error">/JSP/index.jsp</result>
  <result name="success">/JSP/upload.jsp</result>
  </action>
UserLoginAction.java:
public String excute() {
System.out.println("123");
//测试
System.out.println(this.getUsername());
Users users=bllUsers.login(this.getUsername(), this.getPassword());
if (users!=null) {
//测试
System.out.println(users.getAddress());
ActionContext.getContext().getSession().put("login_user", users);
if (users.isAdmin()) {
return "admin_index";
}
return "user_index";
}

return "index";
}

------解决方案--------------------
excute() 
==>

execute()