jsf commandButton导航javax.el.MethodNotFoundException [英] jsf commandButton navigation javax.el.MethodNotFoundException

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

问题描述

您好
我正在尝试测试jsf的导航规则。

Hi I'm trying to test jsf's navigation rules.

我的人bean:

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class Person {
    private int id;
    private String name;
    private int age;

    public Person(){
        id = 1;
        name = "No name!";
        age = 0;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String validate(){
        if(this.name.equals("Evgeny")){
            return "success";
        }else{
            return "failure";
        }
    }
}

我的面孔-config.xml :

My faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>

<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">

    <navigation-rule>
        <from-view-id>/view.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/destination.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>failure</from-outcome>
            <to-view-id>/view.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

</faces-config>

这就是我的形式:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<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">

<h:body>
    <h:form>
        <h:outputText>Some Text!</h:outputText>
        Name:   <h:inputText value="#{person.name}" id="inName"></h:inputText>
            <br></br>
        Age:    <h:inputText value="#{person.age}" id="inAge"></h:inputText> 
            <br></br>
        <h:commandButton value="OK" action="#{person.validate}"></h:commandButton>
    </h:form>
</h:body>
</html>

当我尝试致电person.validate时,我得到 javax.el.MethodNotFoundException 为什么会发生?
我正在使用MyFaces2.0.4和Tomcat 7

When I try to call person.validate I get javax.el.MethodNotFoundException Why that happens? I'm using MyFaces2.0.4 and Tomcat 7

推荐答案

保存所有文件,重建项目,重新部署Web应用程序并重新启动服务器。

Save all files, rebuild the project, redeploy the webapp and restart your server.

换句话说,一切看起来都很好。您只是没有运行您认为正在运行的代码。

In other words, everything looks fine. You are just not running the code you think you're running.

这篇关于jsf commandButton导航javax.el.MethodNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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