出现问题Unable to instantiate Action, Action_SortBook, defined for 'SortBook' in namespace '/'Error creating bean with name 'Action_SortBook' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [Action.SortBook]: Constructor threw exception; nested exception is java.lang.NullPointerException
但其他Action都没出现这样的问题
部分Struts.xml如下:
/sortBooks.jsp
/sortBooks.jsp
部分/applicationContext.xml
scope="prototype">
Action:
public class SortBook extends ActionSupport{
private ArrayList<Book> booklist;
private CategoryService cd = new CategoryServiceImpl();
private BookService bd = new BookServiceImpl();
public CategoryService getCd() {
return cd;
}
public void setCd(CategoryService cd) {
this.cd = cd;
}
public BookService getBd() {
return bd;
}
public void setBd(BookService bd) {
this.bd = bd;
}
private ArrayList<Category> categoryList=cd.ShowList();
public ArrayList<Category> getCategoryList() {
return categoryList;
}
public void setCategoryList(ArrayList<Category> categoryList) {
this.categoryList = categoryList;
}
private int categoryId;
public int getCategoryId() {
return categoryId;
}
public void setCategoryId(int categoryId) {
this.categoryId = categoryId;
}
public ArrayList<Book> getBooklist() {
return booklist;
}
public void setBooklist(ArrayList<Book> booklist) {
this.booklist = booklist;
}
public String execute(){
System.out.println("execute()execute()execute()");
this.setBooklist(bd.SortBook());
return SUCCESS;
}
public String listBookByCategory()
{
System.out.println("listBookByCategory()listBookByCategory()");
booklist=bd.listBooksByCategory(categoryId);
return SUCCESS;
}
}
求大神解答~~~~~~~~~~~~~~~