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

struts1求解!为什么action中传递的actionform是空
这是登录页面的部分代码
HTML code
    <form name="usersForm" method="post" action="logon.do?action=logon">
    <table width="432" height="236" border="0" cellpadding="0" cellspacing="0" background="images/login.gif">
        <tr align="center">
          <td height="128" colspan="2" >&nbsp;</td>
        </tr>
        
        <tr>
          <td width="170" height="31" align="center" >用户名:</td>
          <td width="230" height="31" >
            <input name="username" type="text" class="input">        </td>
        </tr>
        <tr>
          <td width="170" height="29" align="center">密&nbsp;&nbsp;码:</td>
          <td width="230" height="29" ><input name="password" type="password" class="input" ></td>
        </tr>
        <tr>
          <td height="70" colspan="2" align="center" ><input type="submit" name="Submit" value="登陆" class="button">
          &nbsp;
            <input type="reset" name="Submit2" value="重置"class="button"></td>
          </tr>
        
    </table>

这是struts-config.xml
XML code

<struts-config>
  <form-beans>
      <form-bean name="userForm" type="com.ems.actionform.UsersForm" />
  </form-beans>

  <global-forwards>
    <forward name="error" path="/error.jsp" />
  </global-forwards>
  
  <action-mappings>
    <action path="/logon" type="com.ems.action.UsersAction" name="userForm" scope="request">
      <forward name="success" path="/manage.jsp" />
      <forward name="failed" path="/failed.jsp" />
    </action>
  </action-mappings>
</struts-config>


这是UserForm
Java code

package com.ems.actionForm;



import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.ems.model.Users;
import com.ems.util.DateUtil;




public class UsersForm extends ActionForm {
   
    private Long id;

    private String username;

    private String password;

    private Byte sex;

    private String birthday;

    private String createtime;

    private Byte isadmin;

    private String content;
    
    

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    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 Byte getSex() {
        return sex;
    }

    public void setSex(Byte sex) {
        this.sex = sex;
    }

    public String getBirthday() {
        r