首先开始制作网页页面
包括信息添加、信息修改、信息删除、查询4大内容。
代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>首页</title> </head> <body> <div align="center"> <div class="a"> <a href="add.jsp">信息添加</a> </div> <div class="a"> <a href="CourseServlet?method=list">信息修改</a> </div> <div class="a"> <a href="del.jsp">信息删除</a> </div> <div class="a"> <a href="search.jsp">备注查询</a> </div> </div> </body> </html>
然后写了一个add.jsp 添加的内容
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <% Object message = request.getAttribute("message"); if(message!=null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%} %> <div align="center"> <h1 style="color: black;">信息录入</h1> <a href="index.jsp">返回主页</a> <form action="CourseServlet?method=add" method="post" onsubmit="return check()"> <div class="a"> 备注<input type="text" id="name" name="name"/> </div> <div class="a"> 分类<input type="text" id="fenlei" name="fenlei" /> </div> <div class="a"> 金额<input type="text" id="money" name="money" /> </div> <div class="a"> 日期<input type="text" id="time" name="time"/> </div> <div class="a"> <button type="submit" class="b">保 存</button> </div> </form> </div> <script type="text/javascript"> function check() { var name = document.getElementById("name");; var fenlei = document.getElementById("fenlei"); var money = document.getElementById("money"); var time = document.getElementById("time"); } </body> </html>