首页 > Web开发 > 详细

为工程添加组件+改写JSP页面为HTML文件

时间:2015-07-16 17:03:38      阅读:327      评论:0      收藏:0      [点我收藏+]

主要代码

一   配置文件——追加配置项

springMVC-servlet.xml

<!-- 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>

二  将例子改写成HTML

helloWorld.html

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

<form action="init" th:object="${UserBean}" method="post">

<button type="submit" name="login">检索</button>

</form>


login.html

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

<body>

<div th:each="user,status:${list}">

<table>

<tr>

<td>ID:<a th:href="@{delete?(userId=${user.userId})}"><span th:text="${user.userId}">12</span></a></td>

<td>用户名:<span th:text="${user.userName}">123 </span></td>

</tr>

</table>

</div>

</body>



为工程添加组件+改写JSP页面为HTML文件

原文:http://my.oschina.net/u/2411768/blog/479363

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!