Target Unreachable, identifier resolved to null JSF 2.2 [closed]

北战南征 提交于 2019-12-04 15:45:31
kolossus

There's quite a bit wrong with your current code:

  1. You're using the wrong JSF annotations

  2. You're not using JSF-standard tags. Use:

    • <h:head/> instead of <head> (this is required for most ajax functionality in . Without it, the necessary javascript to support ajax cannot be included on the page
    • <h:body> instead of <body>

An HTTP-500 is indicative of an actual bug in your code.

Don't be afraid of 500 error code. just read stack trace carefully. there were some error in your code like Null Pointer Exception. please check this code ans tell the result.

import java.io.Serializable;

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

@ManagedBean
@SessionScoped
public class User implements Serializable {

    private String name;
    private String password;
    private String greeting;

    /**
     * @return
     */
    public String getGreeting() {
        if (name == null ||name.length() == 0)
            return "";
        else
            return "Welcome to JSF2 + Ajax, " + name + "!";
    }

    public String getName() {
        return name;
    }

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

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setGreeting(String greeting) {
        this.greeting = greeting;
    }

}

also please be careful about @kolossus answer and use standard jsf tags and annotations

Try to use different annotation

import javax.faces.bean.ManagedBean;

instead of Java EE 6's

import javax.annotation.ManagedBean;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!