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.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"/>
- 在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" />
转载来源 https://blog.csdn.net/yangwen123222/article/details/79375389