配置thymeleaf的視圖解析器的方法:在webContent目錄下面建立xml文件具體建立的代碼以下:html
<!-- thymeleaf的視圖解析器 --> <bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver"> <property name="prefix" value="/WEB-INF/html/" /> <property name="suffix" value=".html" /> <property name="templateMode" value="HTML5" /> </bean> <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine"> <property name="templateResolver" ref="templateResolver" /> </bean> <bean id="viewResolverThymeleaf" class="org.thymeleaf.spring4.view.ThymeleafViewResolver"> <property name="templateEngine" ref="templateEngine" /> <property name="characterEncoding" value="UTF-8"/> <property name="order" value="0"/> </bean>
2.利用thymeleaf視圖解圖器,實現html在頁面中的靜態映射,使得對頁面的美化更爲方便。java
3.對於html中用到,超連接,傳之,獲取傳值的html代碼。好比:web
<td><a th:href="@{deleteuser?(userId=${userInfo.userId})}"><span th:text="${userInfo.userId}">12</span></a></td> <td><span th:text="${userInfo.username}"></span></td>
form action="initupdate"th:object="${userBean}" method="post">spring
<input name="userId" type="text" th:value="${userBean.userId}" disabled="disabled"/>post
<input name="username" type="text" th:value="${userBean.username}"/>spa
<button name="update"type="submit">update</button>code
</form>orm