main.jsp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <%@ page import="com.xbw.repository.StudentRepository" %>
  2. <%@ page import="com.xbw.entity.Student" %>
  3. <%@ page import="java.util.List" %>
  4. <%@ page import="java.util.ArrayList" %><%--
  5. Created by IntelliJ IDEA.
  6. User: x'b'w
  7. Date: 2021/5/23
  8. Time: 11:28
  9. To change this template use File | Settings | File Templates.
  10. --%>
  11. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  12. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  13. <html>
  14. <head>
  15. <title>主页面</title>
  16. </head>
  17. <body>
  18. <%-- 查询OK--%>
  19. <form action="student1" method="get">
  20. 查询学号为<input type="text" name="selectnum">的同学的名字:<input type="text" name="selectname" readonly value="暂不开放!">
  21. <input type="submit" value="查询"><br>
  22. <input type="hidden" name="method" value="select" />
  23. </form>
  24. <%-- 修改OK--%>
  25. <form action="student1" method="post">
  26. 修改学号为<input type="text" name="updatenum">的同学的名字为:<input type="text" name="updatename"><input type="submit" value="修改"><br>
  27. <input type="hidden" name="method" value="update"/>
  28. </form>
  29. <%-- 增加OK--%>
  30. <form action="student1" method="post">
  31. 增加学号为<input type="text" name="addnum">的同学的名字为:<input type="text" name="addname"><input type="submit" value="增加"><br>
  32. <input type="hidden" name="method" value="add"/>
  33. </form>
  34. <%-- 删除OK--%>
  35. <form action="student1" method="get">
  36. 删除学号为<input type="text" name="deletenum">的同学的名字为:<input type="text" name="deletename" readonly value="暂不开放!">
  37. <input type="submit" value="删除"><br>
  38. <input type="hidden" name="method" value="delete"/>
  39. </form>
  40. <%-- 查询所有-------------------------------------------------------------------------------------------------------%>
  41. <form action="student1" method="get">
  42. <input type="submit" value="查询所有">
  43. </form>
  44. <%-- 查询所有信息:${list}--%>
  45. <table>
  46. <%-- <tr>--%>
  47. <%-- <th>编号</th>--%>
  48. <%-- <th>姓名</th>--%>
  49. <%-- </tr>--%>
  50. <%-- <tr>--%>
  51. <%-- <td>编号</td>--%>
  52. <%-- <td>姓名</td>--%>
  53. <%-- </tr>--%>
  54. <br>
  55. <%-- 查询一条信息:${resnum}--%>
  56. <br>
  57. <table>
  58. <c:choose>
  59. <c:when test="${resnum != null}">
  60. 查询一条信息:
  61. ${resnum}
  62. <tr>
  63. <td>${resnum.num}</td>
  64. <td>${resnum.name}</td>
  65. </tr>
  66. </c:when>
  67. <c:otherwise>
  68. 查无一条信息:null.
  69. </c:otherwise>
  70. </c:choose>
  71. </table>
  72. <br>
  73. <table>
  74. <c:choose>
  75. <c:when test="${list != null}">
  76. 全部信息:
  77. ${list}
  78. <c:forEach items="${list}" var="student1">
  79. <tr>
  80. <td>${student1.num}</td>
  81. <td>${student1.name}</td>
  82. </tr>
  83. </c:forEach>
  84. </c:when>
  85. <c:otherwise>
  86. 查无全部信息:null.
  87. </c:otherwise>
  88. </c:choose>
  89. </table>
  90. <%-- <%--%>
  91. <%-- String sel =(String) request.getAttribute("resnum");--%>
  92. <%-- if (sel != null){--%>
  93. <%-- %>--%>
  94. <%-- <%=--%>
  95. <%-- "当前查询的语句为"+sel--%>
  96. <%-- %>--%>
  97. <%-- <%--%>
  98. <%-- }else {--%>
  99. <%-- %>--%>
  100. <%-- <%=--%>
  101. <%-- "当前查询不到语句:null"--%>
  102. <%-- %>--%>
  103. </table>
  104. </body>
  105. </html>