struts2 属性注入的一个问题

_还行_ 2013-02-20 11:38:23
struts2属性注入的时候,对象的属性只能注入一个,其他属性注入不进去。
例如:user对象 username和password ,页面上写user.username和user.password 只能注入一个username。
...全文
110 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
_还行_ 2013-02-20
  • 打赏
  • 举报
回复
引用 1 楼 hzw2312 的回复:
可以注入了的话就全部都可以的~~~仔细检查是不是哪里写错了字符或者多了空格什么的!
问题解决了,是因为user对象的getter方法没写(我只写了setter方法),因为之前用spring注入对象用的多了,习惯的只写setter方法,但是struts2貌似不可以,看来只能看src才能知道其原理了。
_还行_ 2013-02-20
  • 打赏
  • 举报
回复
引用 2 楼 fangmingshijie 的回复:
看看jsp页面
<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"> </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"> </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"> </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"> </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"> </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"> </td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td height="212" background="${pageContext.request.contextPath}/images/login_08.gif"> </td>
          </tr>
        </table></td>
        <td background="${pageContext.request.contextPath}/images/login_04.gif"> </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="70ad21"> </td>
  </tr>
</table>

 </form>
</body>
_还行_ 2013-02-20
  • 打赏
  • 举报
回复
引用 1 楼 hzw2312 的回复:
可以注入了的话就全部都可以的~~~仔细检查是不是哪里写错了字符或者多了空格什么的!

请求是发送过去了,
  • 打赏
  • 举报
回复
看看jsp页面
BUG胡汉三 2013-02-20
  • 打赏
  • 举报
回复
可以注入了的话就全部都可以的~~~仔细检查是不是哪里写错了字符或者多了空格什么的!

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧