第二次提交
This commit is contained in:
parent
243c7e506c
commit
d9176489dc
|
@ -5,17 +5,25 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class TestController {
|
||||
@RequestMapping("test")
|
||||
public String test(Model model){
|
||||
|
||||
List<User> userList = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
User user = new User();
|
||||
user.setUsername("lzw");
|
||||
user.setClassname("yixin");
|
||||
user.setUsername("lzw "+i);
|
||||
user.setClassname("yixin "+i);
|
||||
userList.add(user);
|
||||
}
|
||||
|
||||
|
||||
model.addAttribute("name","zyx");
|
||||
model.addAttribute("user",user);
|
||||
model.addAttribute("userList",userList);
|
||||
return "test.html";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
spring.application.name=springboot
|
||||
spring.web.resources.static-locations=classpath:/img/
|
|
@ -6,7 +6,15 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1> hello world</h1>
|
||||
<div th:text="${name}"></div>
|
||||
<div th:text="${user.classname}"></div>
|
||||
<table border="1">
|
||||
<tr>
|
||||
<td>姓名</td>
|
||||
<td>班级</td>
|
||||
</tr>
|
||||
<tr th:each="user:${userList}">
|
||||
<td th:text="${user.username}"></td>
|
||||
<td th:text="${user.classname}"></td>
|
||||
</tr>
|
||||
</table>>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue