博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
练习——图书管理系统八(根据图书编号填充图书名称下拉控件和验证手机号)
阅读量:3965 次
发布时间:2019-05-24

本文共 2490 字,大约阅读时间需要 8 分钟。

borrowinfoadd.html

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

//验证手机号码     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; } } }

BookInfoDao.java

/**	 * 查找图书名称	 * @Description 	 * @param bookId	 * @return	 */	public Map
getBookNames(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; }

BookInfoService.java

/**	 * 通过图书ID查找图书名称	 * @Description 	 * @param bookId	 * @return	 */	public Map
getBookNames(String bookId,String remain) {
return bookInfoDao.getBookNames(bookId,remain); }

BookInfoAction.java

/**	 * 查找全部有剩余数量的图书名称	 * @Description 	 * @param request	 * @param response	 * @throws ServletException	 * @throws IOException	 */	protected void getBookNames(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Map
bookNames = 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/

你可能感兴趣的文章
Spring Batch 核心概念
查看>>
Spring Batch 例子: 导入定长文件到数据库
查看>>
正则表达式
查看>>
Java I/O
查看>>
序列化
查看>>
Perl 精萃
查看>>
Perl 简介
查看>>
Perl 注释
查看>>
数据类型之标量
查看>>
调试 Perl 脚本
查看>>
增强的for循环语句
查看>>
方法的可变参数
查看>>
静态导入
查看>>
java 泛型
查看>>
控制结构
查看>>
标准输入输出
查看>>
运算符
查看>>
数据类型之列表与数组
查看>>
比较字符串
查看>>
Java EE 精萃
查看>>