HTML頁與JSP頁

    在HTML中循環遍歷數據庫中數據時不用<c: forEach>而是用< th:--->,<c: forEach>會破壞HTML頁,並在配置文件配置視圖解析器themeleaf,導入幾個重要的包:html

  lombok-1.16.2.jar   thymeleaf-2.1.4.RELEASE.jar     thymeleaf-spring4-2.1.4.RELEASE.jar   unbescape-1.1.0.RELEASE.jarweb

<tr th:each="user,status:${list}">表示循環。spring

   <a th:href="@{deleteid(userID=${user.userID})}">表示連接(格式!)數據庫

   <span th:text="${user.userID}">12</span>用來承接傳過來的值post

   <form action="all" th:object="${UserBean}" method="post">傳值時要用此格式聲明spa

   <input name="password" type="text" th:value="${UserBean.password}"/>用文本框承接傳過來的值code

 

<!-- 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" />
	<property name="order" value="1"/>	
    </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>
相關文章
相關標籤/搜索