本文共 2490 字,大约阅读时间需要 8 分钟。
//验证手机号码 function onPhoneValidation(e) { if (e.isValid) { var pattern = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/; if (pattern.test(e.value) == false) { e.errorText = "手机号码格式不正确"; e.isValid = false; } } }
/** * 查找图书名称 * @Description * @param bookId * @return */ public MapgetBookNames(String bookId,String remain) { Connection connection = JDBCUtil.getConnection(); PreparedStatement pStatement = null; ResultSet rSet = null; String bookId1 = null; String bookName = null; Map map = new HashMap(); try { String sql = "select bookid,bookname from bookinfo where 1 = 1"; if(!StringUtils.isEmpty(bookId)) { sql += " and bookid = '" + bookId + "'"; } if(!StringUtils.isEmpty(remain)) { sql += " and remain " + remain; } pStatement = connection.prepareStatement(sql); rSet = pStatement.executeQuery(); while(rSet.next()) { bookId1 = rSet.getString(1); bookName = rSet.getString(2); map.put(bookId1, bookName); } } catch (Exception e) { e.printStackTrace(); }finally { JDBCUtil.closeConnection(connection, pStatement, null); } return map; }
/** * 通过图书ID查找图书名称 * @Description * @param bookId * @return */ public MapgetBookNames(String bookId,String remain) { return bookInfoDao.getBookNames(bookId,remain); }
/** * 查找全部有剩余数量的图书名称 * @Description * @param request * @param response * @throws ServletException * @throws IOException */ protected void getBookNames(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { MapbookNames = bookInfoService.getBookNames("","> 0"); List books = new ArrayList<>(); Set ids = bookNames.keySet(); for(String id : ids) { BookShow bookShow = new BookShow(); bookShow.setId(id); bookShow.setText(bookNames.get(id)); books.add(bookShow); } response.getWriter().print(JSONObject.toJSONString(books)); } /** * 成员内部类,返回图书编号和图书名称 */ class BookShow{ String id; String text; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getText() { return text; } public void setText(String text) { this.text = text; } }
转载地址:http://truki.baihongyu.com/