我jsp页面有这么一段代码
 <center> <font color="red">用户详细信息</font>
    <table cellpadding="0" cellspacing="0" align="center" border="0" width="80%">
     <thead>
       <tr align="center">
          <th>账号</th>
          <th>姓名</th>
          <th>口令</th>
          <th>性别</th>
          <th>年龄</th>
          <th>爱好</th>  
          <th>操作</th>
        </tr>
     </thead>    <tbody>
          <s:iterator id="mylist" value="#request.list">
         <tr align="center">
          <td><s:property value="#mylist.userId"/></td>
          <td><s:property value="#mylist.userName"/></td>
          <td><s:property value="#mylist.userPwd"/></td>
          <td><s:property value="#mylist.userSex"/></td>
          <td><s:property value="#mylist.userAge"/></td>
          <td><s:property value="#mylist.userFav"/></td>
          <td>
<!--  
          <a href="update.jsp">修改</a>
          -->
          <a href='<s:url action="edit"><s:param name="userId" value="userId"></s:param></s:url>'>修改</a>
          <a href='<s:url action="delete"><s:param name="userId" value="userId"></s:param></s:url>'>删除</a>
          <a href='<s:url action="insert"><s:param name="userId" value="userId"></s:param></s:url>'>添加</a>
             </td>
         </tr>
        </s:iterator>当我点击修改操作后,跳转到action 中,在action是这么接收值的。private String userId;实现它的get和set方法。然后把 id直接传到修改方法中。这么写行吗

解决方案 »

  1.   

    用标签后,标签里面的对象和action里面的名字要一致,这样struts会自动调用set方法赋值,页面也能自动获取该参数的值,页面上是这样写的,逻辑部分就不知道你写的对不对了
      

  2.   

    我这么写就是在action取到的值为空。不知道为什么。标签里的对象是name还是value?
      

  3.   

    property标签使用value属性来指定要输出的对象属性
    param标签使用name属性来指定参数名