thymeleaf 與 jsp轉化對應表

c:forEach與th:each
<select name="stationId" id="stationId" class="form-control" 
          onchange="deviceData.getDevList();">

		<c:forEach var="station" items="${stationInfoList}">
				<option value ="${station.id}" 
<c:if test="${station.id==stationId}">selected="selected"</c:if> >${station.stationName}</option>
			</c:forEach>

</select>
<select name="stationId" id="stationId" class="form-control" onchange="deviceData.getDevList();">
									
<option th:each="station:${stationInfoList}" th:value ="${station.id}"  th:text="${station.stationName}" th:selected="${station.id} eq ${stationId}">${station.stationName}</option>
								
</select>

select對應

<select id="type" name="type" class="form-control" onchange="deviceData.changeType()">
		<option value="1" <c:if test="${type==1}">selected="selected"</c:if>>當天</option>
		<option value="2" <c:if test="${type==2}">selected="selected"</c:if>>近三天</option>
		<option value="3" <c:if test="${type==3}">selected="selected"</c:if>>近一週</option>
		<option value="4" <c:if test="${type==4}">selected="selected"</c:if>>自定義</option>
</select>
<select id="type" name="type" class="form-control" onchange="deviceData.changeType()">
			<option value="1" th:selected="${type==1}">當天</option>
			<option value="2" th:selected="${type==2}">近三天</option>
			<option value="3" th:selected="${type==3}">近一週</option>
			<option value="4" th:selected="${type==4}">自定義</option>
	</select>

時間格式對應:

<div id="timeDiv" class="form-group" style="display: none">
	<label class="search-label">時間 </label>:從

	<input type="text" value="<fmt:formatDate value="${startTime}" type="date" pattern="yyyy-MM-dd" />"  datefmt="yyyy-MM-dd" />

	<label class="search-label">至</label>:

	<input type="text" value="<fmt:formatDate value="${endTime}" type="date" pattern="yyyy-MM-dd" />" datefmt="yyyy-MM-dd" />

</div>
<div id="timeDiv" class="form-group" style="display: none">
		<label class="search-label">時間 </label>:從

		<input type="text" th:value="${#dates.format(startTime,'yyyy-MM-dd')}"  datefmt="yyyy-MM-dd" />

		<label class="search-label">至</label>:

		<input type="text" th:value="${#dates.format(endTime,'yyyy-MM-dd')}"  datefmt="yyyy-MM-dd" />
	</div>

字符串拼接

<c:forEach items="${paramList}" var="data" varStatus="a">

	<th style="width: 6%;">${data.paramName}(${data.unit})</th>

	</c:forEach>
<th  th:each="data :${paramList}" th:text="${data.paramName}+'('+${data.unit}+')'" style="width: 6%;"></th>

自己項目中需要的前臺分頁的代碼:

<footer th:replace="~{templates/page :: pagination}"></footer>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章