struts2属性注入的时候,对象的属性只能注入一个,其他属性注入不进去。
例如:user对象 username和password ,页面上写user.username和user.password 只能注入一个username。
struts属性注入spring

解决方案 »

  1.   

    <body>
    <form action="${pageContext.request.contextPath}/login/loginAction" method="post" id="login_form">
    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td bgcolor="9fc967">&nbsp;</td>
      </tr>
      <tr>
        <td height="604">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="604" background="${pageContext.request.contextPath}/images/login_02.gif">&nbsp;</td>
            <td width="989"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="345" background="${pageContext.request.contextPath}/images/login_1.jpg">&nbsp;</td>
              </tr>
              <tr>
                <td height="47">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="539" height="47" background="${pageContext.request.contextPath}/images/login_05.gif" nowrap="nowrap">&nbsp;</td>
                    <td width="206" background="${pageContext.request.contextPath}/images/login_06.gif" nowrap="nowrap">                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="17%" height="22"><div align="center"><span class="STYLE1">用户</span></div></td>
                        <td width="58%" height="22"><div align="center">
                            <input name="user.username" id="username" type="text" size="15" style="height:17px; border:solid 1px #bbbbbb" />
                        </div></td>
                        <td width="25%" height="22">&nbsp;</td>
                      </tr>
                      <tr>
                        <td height="22"><div align="center"><span class="STYLE1">密码</span></div></td>
                        <td height="22"><div align="center">
                            <input name="user.password" id="password" type="password" size="15" style="height:17px; border:solid 1px #bbbbbb" />
                        </div></td>
                        <td height="22"><div align="center"><img src="${pageContext.request.contextPath}/images/dl.gif" width="39" height="18" id="sub" style="cursor:pointer"></div></td>
                      </tr>
                    </table>
                   
                    </td>
                    <td width="244" background="${pageContext.request.contextPath}/images/login_07.gif" nowrap="nowrap">&nbsp;</td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td height="212" background="${pageContext.request.contextPath}/images/login_08.gif">&nbsp;</td>
              </tr>
            </table></td>
            <td background="${pageContext.request.contextPath}/images/login_04.gif">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td bgcolor="70ad21">&nbsp;</td>
      </tr>
    </table> </form>
    </body>
      

  2.   

    问题解决了,是因为user对象的getter方法没写(我只写了setter方法),因为之前用spring注入对象用的多了,习惯的只写setter方法,但是struts2貌似不可以,看来只能看src才能知道其原理了。