<分区>
通过以下链接挖掘后,我无法解决问题:Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable
我收到以下错误:javax.servlet.ServletException:/Project9.xhtml @13,55 value="#{ProjectBean.income}": Target Unreachable, identifier [ProjectBean] resolved to null
我的表格:
<!DOCTYPE html>
<html xmlns="http://wwww3.org/1999/xhtml"
xmlns:a="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
>
<h:head>
<title>Project9</title>
</h:head>
<h:body>
<h:form>
Income: <h:inputText value="#{ProjectBean.income}"/>
Number of people: <h:inputText value="#{ProjectBean.numPeople}"/>
<h:commandButton value= "Submit" action= "Project9response"/>
</h:form>
</h:body>
</html>
我不确定正确的约定是 wwww3.org 还是 www.3.org,但我都试过了。
我的回复页面:
<!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://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
>
<h:head>
<title><ui:insert name="title">Project 9 response</ui:insert></title>
</h:head>
<h:body>
Am I above the poverty level: #{ProjectBean.abovePovertyLevel()}
</h:body>
</html>
我的 bean :
@ManagedBean
@SessionScoped
public class ProjectBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private double income;
private double numPeople;
//constructor is no arg
public ProjectBean() {
}
public double getIncome() {
return income;
}
public void setIncome(double income) {
this.income = income;
}
public double getNumPeople() {
return numPeople;
}
public void setNumPeople(double numPeople) {
this.numPeople = numPeople;
}
public boolean abovePovertyLevel() {
if ( income < (16460.00 + 4320.00) * (numPeople - 2)){
return false;
}
else {
return true;
}
}
}
我的 faces-config.xml:
<?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_3.xsd"
version="2.3">
</faces-config>
我在 WEB-INF 的 lib 文件夹中有我的 faces-config.xml 和我的 javax-faces.2.2.8.jar 文件 我的bean在Java Resources的src文件夹中
我有另一个名为 helloworld 的项目,其中有几个可以正常工作的小 JSF 项目,我尝试将 project9 复制到 helloworld 并运行它,但我只在该项目上遇到相同的错误
我已经尝试按照人们的建议清理我的项目
这是一个学生项目,也是我对 JSF 和 Tomcat 的第一次介绍。我正在使用 Mac 和 Eclipse 光子。
正如我在代码中的评论中所述,如果我尝试绕过响应 xhtml 文件并直接进入我的 html 表单中的 javabean 方法,我会在 ProjectBean.abovePovertyLevel() 下看到一条下划线和错误“the action值与导航案例结果不匹配”
我不确定上面链接中关于 CDI 等的一些答案,目前我无法理解。