jsp頁面的到html頁面的轉化

首先頂部要引用thmeleaf標籤
html

<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">spring

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">session

對於c:if語句的轉化post

<c:if test="${sessionScope.UVO.guestName==null}">ui

<meta http-equiv="REFRESH" content="0;url=initGuestLogin" />url

</c:if>spa

轉爲orm

<div th:if="${#strings.isEmpty(session.UVO.guestName)}">xml

<meta http-equiv="REFRESH" content="0;url=initGuestLogin" />htm

</div>

對於form裏內容的轉化:

form:form modelAttribute="alipayForm" action="alipaySubmit"

method="post">

<form:hidden path="outTradeNo" value="${alipayForm.outTradeNo}"/>

<form:hidden path="subject" value="${alipayForm.subject}"/>

<form:hidden path="body" value="${alipayForm.body}"/>

<form:hidden path="price" value="${alipayForm.price}"/>

<form:hidden path="showUrl" value="${alipayForm.showUrl}"/>

<form:hidden path="receiveName" value="${alipayForm.receiveName}"/>

<form:hidden path="receiveAddress" value="${alipayForm.receiveAddress}"/>

<form:hidden path="receiveZip" value="${alipayForm.receiveZip}"/>

<form:hidden path="receivePhone" value="${alipayForm.receivePhone}"/>

<form:hidden path="receiveMobile" value="${alipayForm.receiveMobile}"/>

轉化爲

<form name="alipayForm" th:object="${alipayForm}" action="alipaySubmit"

method="post">

<input type="hidden" name="outTradeNo" th:value="${alipayForm.outTradeNo}"/>

<input type="hidden" name="subject" th:value="${alipayForm.subject}"/>

<input type="hidden" name="body" th:value="${alipayForm.body}"/>

<input type="hidden" name="price" th:value="${alipayForm.price}"/>

<input type="hidden" name="showUrl" th:value="${alipayForm.showUrl}"/>

<input type="hidden" name="receiveName" th:value="${alipayForm.receiveName}"/>

<input type="hidden" name="receiveAddress" th:value="${alipayForm.receiveAddress}"/>

<input type="hidden" name="receiveZip" th:value="${alipayForm.receiveZip}"/>

<input type="hidden" name="receivePhone" th:value="${alipayForm.receivePhone}"/>

<input type="hidden" name="receiveMobile" th:value="${alipayForm.receiveMobile}"/>

對於此種語句的轉化<h3>客戶訂單號:${alipayForm.outTradeNo}</h3>

<h3>客戶訂單號:<span th:text="${alipayForm.outTradeNo}"></span></h3>


對於報錯語句${message}<form:errors path="*"></form:errors>

也就是值不能爲空的語句應該這樣修改

<span th:if="${#fields.hasErrors('${alipayForm.*}')}"><span th:errors="${alipayForm.*}"></span></span>

<span th:text="${message}"></span>

基本的修改內容就在這些裏面,小的細節要多注意。

相關文章
相關標籤/搜索