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