tomcat运行报错,求帮忙呀

J2EE 码拜 8年前 (2016-03-17) 868次浏览
test.book部分代码:
package test;
public class Book {
private int id;
private String name;
private double price;
private int bookCount;
private String author;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
……

JSP页面代码:
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=GB18030″>
<title>Insert title here</title>
</head>
<body>
<%request.setCharacterEncoding(“GB18030″);%>
<jsp:useBean id=”book” class=”test.Book”></jsp:useBean>
<jsp:setProperty property=”” name=”book”/>
<%
try{
Class.forName(“com.mysql.jdbc.Driver”);
String url=”jdbc:mysql://localhost:3306/tbook”;
String username=”root”;
String password=”123456″;
Connection conn= DriverManager.getConnection(url,username,password);
String sql= “insert into tbook(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.printStackTrace();
}
%>
<br>
<a href=”index.jsp”>返回</a>
</body>
</html>
运行出现报错:Cannot find any information on property “” in a bean of type “test.Book”
这是怎么回事啊,路径没错呀。
解决方案

5

在上边把包引进来

5

在Jsp中也要引用这个类吧!

5

jsp也是要引入包的

5

贴一下异常栈信息

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明tomcat运行报错,求帮忙呀
喜欢 (0)
[1034331897@qq.com]
分享 (0)