<td>
<s:if test="%{#l.res_scope==1}">完全共享</s:if>
<s:elseif test="%{#l.res_scope==2}">班级共享</s:elseif>
<s:else>好友共享</s:else>
</td>
<h3>发布资源</h3>
<s:form action="upload" method="post" enctype="multipart/form-data">
<s:select name="resource.res_type" list="#{'1':'课件', '2':'教材', '3':'笔记'}" label="选择类型" />
<s:textfield label="名称" name="resource.res_name"/>
<s:textarea label="说明" name="resource.res_desc" rows="10" cols="30"/>
<s:file label="请选择文件" name="upload" ></s:file>
<s:textfield label="费用" name="resource.res_coin" size="6"/>
<s:radio label="共享范围" name ="resource.res_scope" list= "#{'1':'完全共享','2':'班级共享','3':'好友共享'}" value="1"/>
<s:submit name="submit" value="发 布"></s:submit>
</s:form>
实现效果:
struts2标签获取从action中传过来的list集合:
<table border="1" bordercolor="green" cellpadding="0" cellspacing="0">
<tr><td>标识</td>
<td>名称</td>
<td>分享范围</td>
<td>提交时间</td>
<td>附件信息</td>
<td>操作</td>
</tr>
<s:iterator status="status" value="list" var="l">
<tr>
<td>
<s:property value="#status.count" />
</td>
<td><s:a href="detail?id=%{#l.id}">
<s:property value="#l.res_name" />
</s:a>
</td>
<td>
<s:if test="%{#l.res_scope==1}">完全共享</s:if>
<s:elseif test="%{#l.res_scope==2}">班级共享</s:elseif>
<s:else>好友共享</s:else>
</td>
<td>
<s:property value="0" />
</td>
<td>
<s:property value="#l.res_src" />
</td>
<td>
操作
</td>
</tr>
</s:iterator>
</table>
标签:班级,标签,list,学习,Struts2,共享,好友
From: https://blog.51cto.com/u_4427045/6238087