现在这个项目是用SSH来开发的,遇到很多取值方式,在此总结一下,因为一直在用,很容易弄混,取值有问题:
JSP通过url参数值取值:
例如:http://127.0.0.1:8080/portal/login!toAddPag.action?keyCode=1234555
通过以下语句取值:
<%
String keyCode=request.getParameter("keyCode");
%>
在页面中显示值:有以下两种方式:
第一: <%=keyCode %>
第二: ${param.keyCOde}
其次是:在后台action中,通过变量名称,set get之后,为其赋值,在JSP中进行显示:通过 : ${变量名称}
还有就是:生成一些列表list数据,会在JSP中进行遍历
<s:iterator value="players" var="player" status="st">
<li>
<div class="mediaplay_img">
<s:if test="%{template==‘default‘}">
<s:if test="%{defaultPlayer==1}">checked="checked"</s:if>
${player.playerID}
</li>
</s:iterator>
另一种就是通过union进行联合查询无对象的情况下取值如下:
<s:property value=‘#u[0]‘/> <s:if test="%{#u[1]==‘文件夹‘}"> (${u[0]}
<s:iterator value="#request.userVideoResult.resList" var="u">
<tr>
<input type="hidden" value="<s:property value=‘#u[1]‘/>" id="<s:property value=‘#u[0]‘/>">
<input type="hidden" value="<s:property value=‘#u[0]‘/>" id="wjjID">
<td class="video_list_show_1"><input type="checkbox" name="video" value="" /></td>
<s:if test="%{#u[1]==‘文件夹‘}">
<td onclick="editFolder(${u[0]})">编辑 </td>
<td onclick="delFolder(${u[0]})">删除</td>
</s:if><s:else>
<div class="play_view_list"><img src="images/play_view_list.png"/></div>
<img style="width: 100%;height: 100%;" src="images/play_view.png">
</div>
</td>
<td>
<s:if test="%{#u[2]==0}">
<span id="b${userVideo.userVideoID}" style="background: #FF0000 none repeat scroll 0% 0%; border-radius: 12px; padding: 2px 10px;">错误</span>
</s:if>
<s:elseif test="%{#u[3]==‘100%‘}">
<span id="b${userVideo.userVideoID}" style="background:#a0d468; border-radius:12px;padding:2px 10px;">发布</span>
</s:elseif>
<s:elseif test="%{#u[4]==‘‘||#u[4]==null">
<span id="b${userVideo.userVideoID}" style=" background:#fb6e53;padding:2px 10px; border-radius:12px;">排队</span>
</s:elseif>
<s:elseif test="%{#u[5]==‘‘||#u[5]==null)&&#u[3]!=‘100%‘}">
<span id="b${userVideo.userVideoID}" style=" background:#14a6fb;padding:2px 10px; border-radius:12px;">转码</span>
</s:elseif>
<s:else>
<span id="b${userVideo.userVideoID}" style=" background:#FF7E0D; clear:both; padding:2px 10px; border-radius:12px;">待同步</span>
</s:else>
</td>
<td><s:property value=‘#u[5]‘/></td>
<td></td>
<td><s:property value=‘#u[6]‘/></td>
<td> <a href="userVideoAction!toEdit.action?userVideoID=${userVideo.userVideoID}">管理</a></td>
<td> <a href="javascript:delSubmit(‘userVideoAction!delete.action?id=${u[0]}&userVideoPage=${request.userVideoResult.currentPage}&videoStatus=${u[7]}‘);">删除</a></td>
</s:else>
</s:iterator>
版权声明:本文为博主原创文章,未经博主允许不得转载。