Norton740 2017-04-08 04:21 采纳率: 0%
浏览 1833

Unable to instantiate Action的问题

出现问题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;
}

}
求大神解答~~~~~~~~~~~~~~~

  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2017-04-08 15:31
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器