在JSF中获取Null值并显示ERROR:MAC未验证

时间:2016-03-31 06:46:13

标签: java jsf xhtml

我是Jsf的新手,只是创建一个helloworld示例

But I am getting null values in my backing bean can you guys help me out

Here is my backing bean
package practice.backingbeans;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;

import javax.faces.bean.ViewScoped;

@ManagedBean
@ViewScoped

public class Helloworld implements Serializable {

    private String firstname;
    private String lastname;

public Helloworld()
{

}

    public String getFirstname() {
        System.out.println(firstname+"****************************");
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }


}

这是我的xhtml

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html">

<h:head>

    <title>Hello world</title>
</h:head>
<h:body>
    <h:form>

  FirstName:<h:inputText id="fname" value="#{helloworld.firstname}" /><br></br><br></br>
  LastName:<h:inputText id="lname" value="#{helloworld.lastname}" /><br></br><br></br>

<h:commandButton value="Submit" action="success" />     
</h:form>
    </h:body>
</html>

之前当我收到查看异常时,我在我的web.xml中添加了这几行,我的异常得到了解决,但我遇到错误:mac在我的控制台中没有验证

<context-param>
   <param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
   <param-value>true</param-value>
</context-param>
你能帮助我吗????

0 个答案:

没有答案