编写静态页面HTML

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获取包

相关文章
相关标签/搜索