Target Unreachable,标识符解析为空的JSF 2.2 [英] Target Unreachable, identifier resolved to null JSF 2.2

查看:130
本文介绍了Target Unreachable,标识符解析为空的JSF 2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过那些了:

目标无法访问,标识符在JSF中解析为null 2.2

目标无法访问,标识符'authenticator'解析为null"在SEAM中

Java EE 6:目标无法访问,标识符"helloBean'解析为null

目标无法访问,标识符"Bean名称"解析为空

目标无法访问,标识符"Bean名称"解析为空

JSF:/index.xhtml @ 12,80 value =#{LoginBean.username}":目标不可访问,标识符'LoginBean'解析为空

http://www.coderanch .com/t/598907/JSF/java/Target-unreachable-identifier-resolved-null

但他们都没有为我工作.

but none of them worked for me.

Login.xhtml:

Login.xhtml:

<?xml version="1.0" encoding="UTF-8" ?>
<!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:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Login Page</title>
</head>
<body>
    <h:form prependId="false">

        <h3>WELLCOME</h3>
        <br />
        <h3>Enter</h3>
        <table>
            <tr>
                <td><h3>Name</h3></td>
                <td><h:inputText value="#{user.name}" id="name" /></td>
            </tr>
            <tr>
                <td><h3>password</h3></td>
                <td><h:inputSecret value="#{user.password}" id="password" /></td>
            </tr>
        </table>

        <h:commandButton value="Login">
            <f:ajax execute="name password" render="out" />
        </h:commandButton>
        <h3>
            <h:outputText id="out" value="#{user.greeting}" />
        </h3>

    </h:form>
</body>
</html>

User.java:

User.java:

import java.io.Serializable;

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

@ManagedBean
@SessionScoped
public class User implements Serializable {

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

    public String getGreeting() {
        if (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;
    }

}

我没有配置那些web.xml,因为jsf2.2确实如我所知.

I did not config those web.xml, because jsf2.2 does itself as i know.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Ajax</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>

配置界面:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">

</faces-config>

错误是当我单击按钮时

        HTTP Status 500 - /Login.xhtml @17,78 value="#{user.name}": Target Unreachable, identifier 'user' resolved to null

    --------------------------------------------------------------------------------

    type Exception report

    message /Login.xhtml @17,78 value="#{user.name}": Target Unreachable, identifier 'user' resolved to null

    description The server encountered an internal error that prevented it from fulfilling this request.

    exception 

javax.el.PropertyNotFoundException: Target Unreachable, identifier 'user' resolved to null
    at org.apache.el.parser.AstValue.getTarget(AstValue.java:98)
    at org.apache.el.parser.AstValue.getType(AstValue.java:82)
    at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:172)
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
    at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1046)
    at javax.faces.component.UIInput.validate(UIInput.java:976)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1249)
    at javax.faces.component.UIInput.processValidators(UIInput.java:712)
    at javax.faces.component.UIForm.processValidators(UIForm.java:253)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

此警告:

Typee value of the field User.greeting is not used  

但是有2个具有相同get和set的字符串,但没有警告.

But there 2 strings to with same get and set but no warnings for them.

我使用的是Tomcat 7.0.54.

I use tomcat 7.0.54.

推荐答案

您当前的代码有很多错误:

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

  1. 您使用了错误的JSF批注

您没有使用JSF标准标记.使用:

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

  • <h:head/>而不是<head>(这对于.没有它,支持ajax的必要javascript就不会包含在页面上
  • <h:body>而不是<body>
  • <h:head/> instead of <head> (this is required for most ajax functionality in jsf. Without it, the necessary javascript to support ajax cannot be included on the page
  • <h:body> instead of <body>

HTTP-500表示您的代码中存在实际错误.

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

这篇关于Target Unreachable,标识符解析为空的JSF 2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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