displaytag与struts标签间的交互

不知道为什么,在<display:table>中,不能通过OGNL表达式来访问其中迭代的属性值。如:

  1. <display:table name= "${backendListOwnerAction.currentDisplayList}"  pagesize= "10"  id= "ownerTable" >
  2.             <display:column property= "id"  title= "ID"  sortable= "true" ></display:column>
  3.             <display:column property= "ownerName"  title= "业主名称" ></display:column>
  4.             <display:column property= "cityName"  title= "所在城市" ></display:column>
  5.             <display:column property= "publishCount"  title= "发布的房源数"  sortable= "true" ></display:column>
  6.             <display:column property= "registDate"  title= "注册日期" >
  7.             </display:column>
  8.             <display:column title= "操作"  autolink= "true"  >
  9.                 <a href="
  10.                 <s:url action= "backendListOwnerAction!viewOwnerDetail" >
  11.                   <s:param name= "ownerId"  value= "id" ></s:param>               </s:url>
  12.                  " target=" _blank"> 详细信息</a> 
  13.                 | 
  14.                 <a href="
  15.                     <s:url action= "backendListOwnerAction!deleteOwner" >
  16.                         <s:param name= "ownerId"  value= "id" />
  17.                     </s:url>
  18.                  " onclick=" return  deleteConfirm()">删除</a>
  19.             </display:column>
  20.         </display:table>

本来是想吧第一行的id通过参数<s:param>传递给ownerId,但是传递并不成功。

后来想到,可以用jstl的<c:set>先把参数设到request中,之后就可以在struts标签中通过#request方式把 参数读出来了。修改后的代码为:

  1. <display:table name= "${backendListOwnerAction.currentDisplayList}"  pagesize= "10"  id= "ownerTable" >
  2.             <display:column property= "id"  title= "ID"  sortable= "true" ></display:column>
  3.             <display:column property= "ownerName"  title= "业主名称" ></display:column>
  4.             <display:column property= "cityName"  title= "所在城市" ></display:column>
  5.             <display:column property= "publishCount"  title= "发布的房源数"  sortable= "true" ></display:column>
  6.             <display:column property= "registDate"  title= "注册日期" >
  7.             </display:column>
  8.             
  9.             <c:set value= "${ownerTable.id}"  var= "id"  scope= "request" ></c:set>
  10.             
  11.             <display:column title= "操作" >
  12.                 <a href="
  13.                 <s:url action= "backendListOwnerAction!viewOwnerDetail" >
  14.                     <s:param name= "ownerId"  value= "#request.id" ></s:param>
  15.                 </s:url>
  16.                  " target=" _blank"> 详细信息</a> 
  17.                 | 
  18.                 <a href="
  19.                     <s:url action= "backendListOwnerAction!deleteOwner" >
  20.                         <s:param name= "ownerId"  value= "#request.id" />
  21.                     </s:url>
  22.                  " onclick=" return  deleteConfirm()">删除</a>
  23.             </display:column>
  24.         </display:table>

 

虽然绕了一个圈子,总算解决了displaytag与struts标签间传递参数的问题。

 

你可能感兴趣的:(C++,c,struts,C#)