额,刚开始学SSH~~
[color=darkred]源码:[/color]
………… ………… …………大类: 小类:
[color=darkred]bigCateList是通过BookDao类中的方法获取的,代码如下:[/color]
public List getBigCate() {
try {
Session session = MySessionFactory.currentSession();
MySessionFactory.beginTransaction();
List results = session.createQuery("from Bigcate").list();
MySessionFactory.commitTransaction();
MySessionFactory.closeSession();
if (results != null && results.size() > 0) {
return results;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
[color=darkred]表单提交的Action addBook方法的代码 如下 [/color]
public String addBook(){
Book book = new Book();
BookDao bookDao = new BookDaoImpl();
try{
book.setName(new String(bookname.getBytes("ISO-8859-1"),"GBK"));
book.setISBN(new String(ISBN.getBytes("ISO-8859-1"),"GBK"));
book.setAuthor(new String(author.getBytes("ISO-8859-1"),"GBK"));
book.setPress(new String(press.getBytes("ISO-8859-1"),"GBK"));
book.setPrice(price);
book.setSpecial(special);
book.setSalePrice(salePrice);
book.setInfor(new String(infor.getBytes("ISO-8859-1"),"GBK"));
book.setBigCateId(new String(bigCateId.getBytes("ISO-8859-1"),"GBK"));
book.setSmallCateId(new String(smallCateId.getBytes("ISO-8859-1"),"GBK"));
bookDao.addBook(book);
}catch (Exception ex) {
System.out.println("在执行BookMgrAction类中的addBook方法时出错:\n");
ex.printStackTrace();
}
return SUCCESS;
}
[color=darkred]表单提交后出错:[/color]
严重: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'bigCateId': The requested list key 'bigCateList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]