<%@ page language="java" conentType="tex/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<! DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "httpt://www.w3.org/">
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<html>
<head>
<meta http-equiv="Content-Type" content="tex/html; charset=UTF-8">
<title>添加结果</title>
</head>
<body>
<%request.setCharacterEndcoding("UTF-8);%>
<jsp:useBean id="book"class="com.lyq.bean.Book"></jsp:useBean>
<jsp:setProperty property="*"name="book"/>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://locallhost:3306/db_database10";
String username="root";
String password="111";
Connection conn=DriverManager.getConnection(url,username,password);
String sql="insert into tb_books(name,price,bookCount,author)values(?,?,?,?)";
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, book.getName());
ps.setDouble(2, book.getPrice());
ps.setInt(3, book.getBookCount());
ps.setString(4, book.getAuthor());
int row =ps.executeUpdate();
if(row > 0){
out.print("成功添加了"+ row + "条数据!");
}
ps.close();
conn.close();
} catch (Exception e) {
out.print("图书信息添加失败! " );
e.printStackTrack();
}
%>
<br>
<a href="index.jsp">返回</a>
</body>
</html>
问题1:Description Resource Path Location Type
String literal is not properly closed by a double-quote AddBook.jsp /111/WebRoot/WEB-INF line 14 JSP Problem
问题2:Description Resource Path Location Type
Undefined type: com.lyq.bean.Book AddBook.jsp /111/WebRoot/WEB-INF line 15 JSP Problem
------解决思路----------------------
<%request.setCharacterEndcoding("UTF-8");%> 引号少了
<%@page import="com.lyq.bean.Book"%> 先引进来试试。