用jsf调用方法出现问题,代码如下:
public class Login {
private String username;
private String password;
//getter() , seter()方法省略
public String check() {
if( “hnisi”.equals(password) ) {
return “seccess”;
}else {
return “failure”;
}
}
}
jsp里的jsf代码:
<f:view>
<h:form>
<h:outputLabel value=”name:” />
<h:inputText id=”username” value=”#{login.username }” required=”true”>
<f:validateLength maximum=”10″ minimum=”1″></f:validateLength>
</h:inputText>
<h:outputLabel value=”pass:” />
<h:inputSecret value=”#{login.password }”></h:inputSecret>
<h:commandButton value=”Login” action=”#{login.check }”></h:commandButton>
<h:message for=”username”></h:message>
</h:form>
</f:view>
faces-config.xml配置:
<faces-config>
<managed-bean>
<managed-bean-name>login</managed-bean-name>
<managed-bean-class>com.hnisi.item.demo.Login</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>userList</managed-bean-name>
<managed-bean-class>com.hnisi.item.demo.UserList</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/login.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/hello.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/error.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
报错::::!
严重: #{login.check }: javax.faces.el.MethodNotFoundException: check : com.hnisi.item.demo.Login.check ()
javax.faces.FacesException: #{login.check }: javax.faces.el.MethodNotFoundException: check : com.hnisi.item.demo.Login.check ()
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1760)
at java.lang.Thread.run(Thread.java:744)
请问这是什么原因,怎样调用那个验证的方法????