struts2项目迁移为springmvc项目时jsp标签变化记录

1、引入spring标签(使用Struts时也要引入Struts标签,如s标签)

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %> 
2、标签使用

2.1 判断:

在Struts中:
<s:if test="dentity.type==1"><b class="cnm_lpt"></b>
</s:if>
<s:else><b class="cnm_lps"></b>
</s:else>

在spring中:
一个条件:<c:if test="${device.typeId==7}">测试</c:if>
多个条件使用choose标签包裹:
<c:choose>
    <c:when test="${device.typeId == 7 }"><b class="cnm_lpt"></b></c:when>
    <c:otherwise><b class="cnm_lps"></b></c:otherwise>
</c:choose>

2.2 遍历

在Struts中:
<s:iterator value="%{resultList}" id="data" status="sta">
	<td>物联网适配器编号:</td>
	<td><a href="viewdetail.action?detailId=<s:property value="id"/>&deviceKey=<s:property value="devicekey"/>"><s:property value="code"/> </a></td>
</s:iterator>

在spring中:
<c:forEach items="${rows }" var="row" varStatus="vs">
	          <tr>
			    <input type="hidden" id="typeId_${row.adaptorCode}" value="${row.typeId}"/>
	            <td>
	             <a href="jkxq?deviceId=${row.id }&adaptorCode=${row.adaptorCode}&typeId=${row.typeId}&sort=happen_time&order=DESC" style="text-decoration:underline;">${row.code }</a>
            	</td>
	           
	            </tr>
</c:forEach>

2.3 变量

在Struts中:
<p>变频器型号:<i><s:property value="dentity.model"/></i></p>

在spring中:
<p>变频器型号:<i>${device.model }</i></p>

2.4 格式化

时间格式化:

<fmt:formatDate value="${record.operateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
2.5 其他 input 隐藏框

在Struts中:
<s:hidden name="dentity.type" id="dtype"></s:hidden>

在spring中:
<input type="hidden" id="dtype" value="${device.typeId }"/>

2.6 国际化

spring国际化标签
<spring:message code="project.monitor.adaptor.code" />

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值