类型不一致,出现错误
解决方法:利用工具类进行类型转换(如图所示)即可解决
1 String name = request.getParameter("name"); 2 String author = request.getParameter("author"); 3 String priceStr = request.getParameter("price"); 4 String salesStr = request.getParameter("sales"); 5 String stockStr = request.getParameter("stock"); 6 int sales = Integer.parseInt(salesStr); 7 int stock = Integer.parseInt(stockStr); 8 double price = Double.parseDouble(priceStr); 9 Book book = new Book(name, author, price, sales,stock);