javax.el.MethodNotFoundException:找不到方法:JSF [英] javax.el.MethodNotFoundException: Method not found: JSF

查看:142
本文介绍了javax.el.MethodNotFoundException:找不到方法:JSF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JSF尝试简单的应用程序时出现错误.

I am getting error while trying a simple application with JSF.

javax.el.MethodNotFoundException: Method not found: com.jsf.training.beans.TravelBean@4b6b8628.travelInfo()
at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:245)
at org.apache.el.parser.AstValue.invoke(AstValue.java:271)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:818)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

我的托管bean是:

@ManagedBean (name="travelBean")
@SessionScoped
public class TravelBean {

private int index = 0;
private String source;
private String destination;
private Date date;
java.sql.Date sqlDate;
private boolean visible = false;

public boolean isVisible() {
    return visible;
}
public void setVisible(boolean visible) {
    this.visible = visible;
}
public TravelBean() {

}
public String getSource() {
    return source;
}
public void setSource(String source) {
    this.source = source;
}
public String getDestination() {
    return destination;
}
public void setDestination(String destination) {
    this.destination = destination;
}
public Date getDate() {
    return date;
}
public void setDate(Date date) {
    this.date = date;
}

public int getIndex() {
    return index;
}

public void setIndex(int index) {
    this.index = index;
}

public void getDateInSql() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    sdf.format(date);
    sqlDate = new java.sql.Date(date.getTime());
}
public void getTravelInfo() throws SQLException {
    setVisible(true);
    /*SearchServiceImpl search = new SearchServiceImpl();
    search.searchTrainsService(travelBean);*/
    System.out.println("********** in travel Bean :" +source +destination +date);
    TrainBean tb = new TrainBean();
    tb.getTrainsList(source,destination,sqlDate);
}

和我的xhtml:

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<script name="jquery/jquery.js" library="primefaces"></script>
<h:outputStylesheet library="css" name="resources/css/table-style.css"  />
</h:head>
<h:body>
<h:form>
<p:growl id="message"></p:growl>
<p:tabView activeIndex="#{travelBean.index}" dynamic="true" effect="fade" effectDuration="fast">
     <p:tab title="Trains">

        <h:form>
            <h:outputText value="Source"/>:<h:inputText id="source" value="#{travelBean.source}"></h:inputText>
            <h:outputText value="Destination"/>:<h:inputText id="destination" value="#{travelBean.destination}"></h:inputText>
            <h:outputText value="Date"/>:<p:calendar id="date" value="#{travelBean.date}"></p:calendar>
            <h:commandButton value="Search Trains" update="table-wrapper" action="#{travelBean.travelInfo}" actionListener="#{travelBean.travelInfo}" > 
                <!-- <f:ajax execute="@this source destination date" render="output" /> -->
                 <f:attribute name="source" value="#{travelBean.source}"/>
                 <f:attribute name="destination" value="#{travelBean.destination}"/>
                 <f:attribute name="date" value="#{travelBean.date}"/>
            </h:commandButton>
           <h2><h:outputText id="output" value="#{travelBean.source} #{travelBean.destination} #{travelBean.date}"/></h2> 
        </h:form>

    </p:tab> 
    <p:tab title="Flights">
        <h1>Search flights by routes</h1>
         <h:form>
            <h:outputText value="Source"/>:<h:inputText id="source" value="#{travelBean.source}"></h:inputText>
            <h:outputText value="Destination"/>:<h:inputText id="destination" value="#{travelBean.destination}"></h:inputText>
            <h:outputText value="Date"/>:<h:inputText id="date" value="#{travelBean.date}"></h:inputText>
            <h:commandButton value="Search Flights" >
                <f:ajax execute="@form" render="output" />
            </h:commandButton>

            <h2><h:outputText id="output" value="#{travelBean.source}"/>        </h2>
         </h:form> 

    </p:tab>
</p:tabView>


</h:form>

</h:body>

</html>

我查看了其他问题,并尝试了答案,但没有任何效果. 任何帮助都将受到高度赞赏.预先感谢!

I have looked at the other questions, and tried the answer but nothing worked. Any help is highly appreciated. Thanks in advance!

推荐答案

action="#{travelBean.travelInfo}"是一种操作方法.搜索适当的方法时,只有value方法会将travelInfo从EL表达式转换为getTravelInfo().在操作方法中,托管bean中应该确实存在travelInfo()方法,但实际上并非如此.

action="#{travelBean.travelInfo}" is an action method. Only value methods converts travelInfo from EL expression to getTravelInfo() when searching for appropriate method. In action method exactly travelInfo() method is expected to be present in your managed bean, but it isn't.

这篇关于javax.el.MethodNotFoundException:找不到方法:JSF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆