0
我真的不知道問題的原因是什麼。我用hibenate和JSF創建了一個網站,後來又決定整合Spring框架,但最終還是遇到了問題。添加彈簧配置後託管bean不工作
我的託管bean「loginbean」工作正常。它也可以識別JSF頁面中的方法,但是當我運行該應用程序時,會看到一條「錯誤消失」消息。
我的豆:
@ManagedBean(name="loginBean")
@SessionScoped
public class LoginBean {
private String username;
private String password;
private int activeindex;
public String Dirige(int a){
setActiveindex(a);
if (a == 0){
return "/Menu.jsf";
}else{
if (a == 1) {
return "/pagess/pagesFabricant/Fabricant.jsf";
}else{
if (a == 2) {
return "/pagess/pagesComposant/Composant.jsf";
}else{
if(a == 3){
return "/pagess/pagesDeq/DEQ.jsf";
}
}
}
}
return null;
}
}
我在加入SpringBeanFacesELResolver
faces-config.xml中:
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application> on faces.config.xml
,我也包括在web.xml中的相關聽衆:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/application.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
我的看法:
<p:tabMenu activeIndex="#{loginBean.activeindex}">
<p:menuitem value="Home" icon="ui-icon-star" action="#{loginBean.Dirige(0)}" />
<p:menuitem value="Fabricants" icon="ui-icon-wrench" action="#{loginBean.Dirige(1)}" />
<p:menuitem value="Composants" icon="ui-icon-search" action="#{loginBean.Dirige(2)}"/>
<p:menuitem value="Dossier d'equivalence" icon="ui-icon-document" action="#{loginBean.Dirige(3)}"/>
</p:tabMenu>
最後這是我得到的錯誤:
Grave: javax.el.MethodNotFoundException: /templates/template.xhtml @42,95 action="#{loginBean.Dirige(1)}": Method not found: [email protected](java.lang.Long)
javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: /templates/template.xhtml @42,95 action="#{loginBean.Dirige(1)}": Method not found: [email protected](java.lang.Long)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:92)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
只有一兩件事我不understund它..whay當我eleminate dirige(INT一){setindex(一)},由另一梅索德diride0(){setindex(0)}這行得通corect ...不帶參數的小括號!!!!!這就像沒有春天! – FERESSS 2013-04-21 21:53:58
你的方法以大寫字母D開頭,我會先解決這個問題。 – atamanroman 2013-04-21 23:25:41
你的例外清楚地表明你傳遞的參數是一個'Long',你的支持bean中的方法接受'int'。 – kolossus 2013-04-22 03:49:14