项目描述
上传时间
浏览人数
1.html部分
<!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>Title</title> <!-- 引用Js,css --> <script type="text/javascript" th:src="@{/router/jquery.min.js}"></script> <script type="text/javascript" th:src="@{/router/bootstrap.min.js}"></script> <link rel="stylesheet" type="text/css" th:href="@{/router/bootstrap.min.css}"> </head> <body> <h3> <!--<table>--> <!--<tr>--> <!--<th>id</th>--> <!--<th>姓名</th>--> <!--<th>课程</th>--> <!--<th>成绩</th>--> <!--<th>是否结婚</th>--> <!--</tr>--> <!--<tr th:each="s,state:${li}" th:switch="${state.count}">--> <!--<td th:text="${s.id}"></td>--> <!--<td th:text="${s.name}"></td>--> <!--<td th:text="${s.course}"></td>--> <!--<td th:case="1" th:class="${s.scores>90?'ps ps-1': 'ps ps-1 '}"th:text="${s.scores}"></td>--> <!--<td th:case="2" th:class="${s.scores>90?'ps ps-2': 'ps ps-2 '}"th:text="${s.scores}"></td>--> <!--<td th:case="3" th:class="${s.scores<60?'ps ps-3': 'ps ps-3 '}"th:text="${s.scores}"></td>--> <!--<td th:case="*" th:class="${s.scores>50?'ps ': 'ps no-pass'}"th:text="${s.scores}"></td>--> <!--<td th:if="${s.is_married==true}" style="color: red">已婚</td>--> <!--<td th:unless="${s.is_married}">未婚</td>--> <!--</tr>--> <!--</table>--> <!--</h3>--> </body>
2.class部分
package com.han.sb1026.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Controller public class StudentsController { @Autowired private HttpServletRequest request; @RequestMapping("/s") public String info(){ Map<String,Object> s = new HashMap<>(); s.put("id",01); s.put("name","小韩"); s.put("course","Java"); s.put("scores" ,98); s.put("is_married",true); Map<String,Object> t = new HashMap<>(); t.put("id",02); t.put("name","小王"); t.put("course","UI"); t.put("scores" ,95); t.put("is_married",false); Map<String,Object> u = new HashMap<>(); u.put("id",03); u.put("name","小陈"); u.put("course","设计"); u.put("scores" ,85); u.put("is_married",false); Map<String,Object> d = new HashMap<>(); d.put("id",04); d.put("name","小刘"); d.put("course","语文"); d.put("scores" ,58); d.put("is_married",true); List< Map<String,Object>> li = new ArrayList<>(); li.add(s); li.add(t); li.add(u); li.add(d); request.setAttribute("li",li); return "Students.html"; } }