且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JSP和MySQL-在数据库中查找特定项目

更新时间:2023-12-01 10:27:40

您的findBook方法的返回类型为int,但实际上返回的是Book类型的对象.因此它将无法编译.

Your findBook method has return type as int, but it is actually returning an object of type Book. So it won't compile.

您可以在ManagerBook类中声明Book类型的实例变量,例如

You can declare an instance variable of type Book in ManagerBook class, say

Book searchedBook;

现在在您的findBook方法中,将此变量值设置为SQL查询返回的书,并返回一个int值1.

Now in your findBook method, set this variable value to the book returned by your SQL query and return an int value 1.

在JSP中,您可以使用:

In JSP, you can use :

    <tr>
        <td><%=bm.getSearchedBook().getIsbn() %></td>
        <td><%=bm.getSearchedBook().getTitle() %></td>
    </tr>