编写静态页面HTML

1.controller.java:对删除数据后,对数据显示进行刷新。把删除操作以后的数据用列表的形式显示出来。

@RequestMapping(value = "/delete", method = RequestMethod.GET)

    public String delete(UserBean userBean,Model model) {

int result = helloWorldService.deleteUser(userBean);

List<UserBean> refresh = helloWorldService.searchUser(userBean);

           model.addAttribute("list", refresh);

        return "login";     }

2.helloWorld.html

/html中要加下面的代码。

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

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


你可能感兴趣的:(编写静态页面HTML)