1.controller.java:對刪除數據後,對數據顯示進行刷新。把刪除操做之後的數據用列表的形式顯示出來。html
@RequestMapping(value = "/delete", method = RequestMethod.GET)java
public String delete(UserBean userBean,Model model) {spring
int result = helloWorldService.deleteUser(userBean);app
List<UserBean> refresh = helloWorldService.searchUser(userBean);post
model.addAttribute("list", refresh);spa
return "login"; }orm
2.helloWorld.htmlxml
/html中要加下面的代碼。htm
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> get
<form action="init" th:object="${serBean}" method="post" >//用來獲取userBean和值。
<input name="userId" type="text"/>
<button type="submit" name="login">denglu</button>
</form>
3.login.xml: th:th:each="userInfo, varStatus:${list}"的做用:th:XXx都是thymeleaf的標籤,th:each是迭代集合用法
<div th:each="userInfo, varStatus:${list}">
在html連接的規則以下:
//<span ></span>標籤的做用:<span> 在CSS定義中屬於一個行內元素,在行內定義一個區域,也就是一行內能夠被 <span> 劃分紅好幾個區域,從而實現某種特定效果。 <span> 自己沒有任何屬性。
<td><a th:href="@{delete?(userId=${userInfo.userId})}"><span th:text="${userInfo.userId}"></span></a></td>
<td><span th:text="${userInfo.userName}"></span></td>
4,導入三個jar包,兩個thymeleaf-2.1.4.RELEASE.jar,thymeleaf-spring4-2.1.4.RELEASE.jar和一個unbescape-1.1.0.RELEASE.jar
5,在springMVC-servlet.xml 中填寫thymeleaf的視圖解析器代碼,更改這段代碼
<bean id="viewResolverThymeleaf" class=" org.thymeleaf.spring4.view.ThymeleafViewResolver">
在ThymeleafViewResolver方法中按F2獲取包