找不到方法:class com.obs.bean.SearchBean $$ EnhancerBySpringCGLIB $$ e348f43d.getSearchBookList()

时间:2015-04-24 16:12:15

标签: java spring jsf

我在search.xhtml页面中遇到了这个例外:

javax.servlet.ServletException: Method not found: class com.obs.bean.SearchBean$$EnhancerBySpringCGLIB$$e348f43d.getSearchBookList()
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause
javax.el.MethodNotFoundException: Method not found: class com.obs.bean.SearchBean$$EnhancerBySpringCGLIB$$e348f43d.getSearchBookList()

我在commandButton页面中有一个home.xhtml,如下所示:

<h:form id="searchForm">
    <p:inputText id="srchF" value="#{searchBean.searchKeyword}"/>
    <h:commandButton styleClass="srchBtn" value="search" action="#{searchBean.search()}"/>
</h:form>

以下是search.xhtml页面中的表格:

<h:dataTable id="searchTable" var="srch" value="#{searchBean.getSearchBookList()}">
    <h:column>
        <f:facet name="header">Book title</f:facet>
        <h:outputText value="#{srch[0]}"/>
    </h:column>
</h:dataTable>

这是search bean

@ManagedBean
@SessionScoped
@Component
public class SearchBean {

private String searchKeyword;
private List<Book> searchBookList;
@Autowired
private BookDao bookDao;

@Transactional
public String search() throws IOException {
    searchBookList = new ArrayList<Book>();
    searchBookList = bookDao.findByTitle(getSearchKeyword()).list();
    System.out.println("size of list: " + searchBookList.size()); //list size is >1
    return "search?faces-redirect=true";
}

public List<Book> getSearchBookList() {
    return searchBookList;
}

public void setSearchBookList(List<Book> searchBookList) {
    this.searchBookList = searchBookList;
}

查询结果与数据一起存在。

此代码有什么问题?

更新

我尝试value="#{searchBean.searchBookList}"并收到此错误:

javax.el.PropertyNotFoundException: Property 'searchBookList' not found on type com.obs.bean.SearchBean$$EnhancerBySpringCGLIB$$e348f43d

0 个答案:

没有答案