📄 book_add.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="error.jsp" %><%@ include file="initialization.jsp" %><% String bookName=request.getParameter("bookName");String author=request.getParameter("author");String price=request.getParameter("price");String totality=request.getParameter("totality");String description=request.getParameter("description");String sort=request.getParameter("sort");String year=request.getParameter("year");String month=request.getParameter("month");String day=request.getParameter("day");String[] bookSorts=xml.getElementsValues("/System/BookSort");String requestPage=request.getParameter("request");String thisPage=application.getRealPath(request.getRequestURI());if(requestPage!=null&&thisPage.equals(requestPage)) //如果请求页面非空{ if(!bookName.equals("")&&!author.equals("")&&!price.equals("")&&!totality.equals("")) { float bookPrice=0.0f; int bookTotality=0; String intReg="^[\\d]+$"; String floatReg= "^[\\d]+.?[\\d]*$"; if(totality.matches(intReg)) { bookTotality=Integer.parseInt(totality); if(price.matches(floatReg)) { bookPrice=Float.parseFloat(price); String date=year.trim()+"-"+month.trim()+"-"+day.trim(); ResultSet rs=mysql.getResultSet("select * from book where bookName='"+bookName+"' and author='"+ author+"' and publishDate='"+date+"';"); if(rs!=null&&rs.first()) { out.print("<script language='JavaScript'>alert('已经存在此书目!');</script>"); } else { String stat="insert into book(bookName,author,sort,price,description,publishDate,totality,stocks) " + "values('"+bookName+"','"+author+"','"+sort+"',"+bookPrice+",'"+description+"','"+ date+"',"+bookTotality+","+bookTotality+");"; mysql.executeStatement(stat); out.print("<script language='JavaScript'>alert('书目添加成功!');</script>"); } } else { out.print("<script language='JavaScript'>alert('价格只能是浮点数或整数!');</script>"); } } else { out.print("<script language='JavaScript'>alert('数量只能是整数!');</script>"); } } else { out.print("<script language='JavaScript'>alert('输入数据不全,请重新输入!');</script>"); }} %><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title></head><body><table width="550" height="455" border="0" cellspacing="0" cellpadding="0" > <tr> <td height="455"> <form id="form1" name="form1" method="post" action=""> <table width="526" cellpadding="0" cellspacing="0" border="1" bordercolor="#C2D1E9" style=" border-bottom-color:#3399CC; border-left-color:#3399CC; border-right-color:#3399CC; border-top-color:#3399CC;font-size:13px" > <tr> <td width="88" height="27" align="right">书 名:</td> <td width="432"> <input name="bookName" type="text" id="bookName" size="24" maxlength="50" /> * <input name="request" type="hidden" id="request" value=<%="\""+thisPage+"\""%>></td> </tr> <tr> <td height="25" align="right">类 型:</td> <td> <select name="sort" id="sort"> <% for(int i=0;i<bookSorts.length;i++){ %> <option value=<%="\"" +bookSorts[i]+ " \""%>><%= bookSorts[i] %></option> <%} %> </select> *</td> </tr> <tr> <td height="25" align="right"> 作 者:</td> <td><input name="author" type="text" id="author" size="24" maxlength="50" /> *</td> </tr> <tr> <td height="25" align="right">价 格:</td> <td><input name="price" type="text" id="price" size="24" maxlength="10" /> (元)*</td> </tr> <tr> <td height="25" align="right"> 出版日期:</td> <td> <select name="year" id="year"> <% for(int i=1980;i<=dateTime.getYear();i++){ %> <option value=<%="\"" +i+ " \""%>><%= i %></option> <%} %> </select> 年 <select name="month" id="month"> <% for(int i=1;i<=12;i++){ %> <option value=<%="\"" +i+ " \""%>><%= i %></option> <%} %> </select> 月 <select name="day" id="day"> <% for(int i=1;i<=31;i++){ %> <option value=<%="\"" +i+ " \""%>><%= i %></option> <%} %> </select> 日 *</td> </tr> <tr> <td height="25" align="right">数 量:</td> <td><input name="totality" type="text" id="totality" size="24" maxlength="10" /> *</td> </tr> <tr> <td height="25" colspan="2" align="center">简 介</td> </tr> <tr> <td height="70" colspan="2" align="center"> <textarea name="description" cols="70" rows="10" id="description"></textarea> </td> </tr> <tr> <td height="27" colspan="2" align="right"> <input type="submit" name="Submit" value="提交" /> <input type="reset" name="Submit2" value="重置" /> </td> </tr> </table> </form> </td> </tr></table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -