<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>spring.thymeleaf.cache=false
package com.javaxl.springboot01.entity;
public class User {
private Integer uid;
private String userName;
private String password;
public User(Integer uid, String userName, String password) {
this.uid = uid;
this.userName = userName;
this.password = password;
}
public User() {
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
package com.javaxl.springboot01.controller;
import com.javaxl.springboot01.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.ArrayList;
import java.util.List;
@Controller
public class IndexController {
@RequestMapping("/user/list")
public ModelAndView index(){
ModelAndView mav = new ModelAndView();
mav.setViewName("/user/list");
List list = new ArrayList();
list.add(new User(1,"张三","123"));
list.add(new User(2,"李四","456"));
mav.addObject("userList",list);
mav.addObject("msg","用户列表");
return mav;
}
}
<html xmlns:th="http://www.thymeleaf.org">




备案号:湘ICP备19000029号
Copyright © 2018-2019 javaxl晓码阁 版权所有