迭代通过ArrayList <object>“无法解析或不是字段”</object>

时间:2014-04-01 04:54:34

标签: java jsp session

错误

An error occurred at line: 18 in the jsp file: /BookStoreHome.jsp
title cannot be resolved or is not a field
15: <% 
16: ArrayList<Book> book_list = (ArrayList<Book>)session.getAttribute("books"); 
17: for (int i = 0; i < book_list.size(); i++) {%>
18: <%= book_list.get(i).title %>,
19: <% } %>
20: 
21: </body>


首先,我将书籍设置为ArrayList并存储在会话中 用户逻辑类

ArrayList<Book> book_list = bsl.selectBooks();
session.setAttribute("books", book_list);

图书类

public class Book {

    public String isbn;
    public String title;
    public double price;
    public String genre;
    public int format;
    public String publisher;
    public int publisherYear;
    public int count;
    public String author;
    public String date;


    public Book(String _isbn, String _title, double _price, String _genre, int _format, 
            String _publisher, int _publisheryear, int _count, String _author){
        title = _title;
        isbn = _isbn;
        price = _price;
        genre = _genre;
        format = _format;
        publisher = _publisher;
        publisherYear = _publisheryear;
        count = _count;
        author = _author;
    }

0 个答案:

没有答案