我遇到了问题,我在任何地方都没有发现问题。
我的index.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">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<h:outputText value="Enter product name"/>
<h:inputText value="#{user.name}" /> <br/>
<h:outputText value="Enter qty"/>
<h:inputText value="#{user.qty}" /> <br/>
<h:outputText value="Enter price"/>
<h:inputText value="#{user.price}" /> <br/>
<h:commandButton value="Add item" action="#{user.add}" />
</h:form>
</h:body>
User.java页面是:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class User {
private String name;
private int qty;
private double price;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
this.qty = qty;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String add(){
System.out.println("product inserted..");
System.out.println(this.name+" "+this.qty+" "+this.price);
return "Success";
}
}
当我运行它时 /index.xhtml @ 12,48 value =“#{obj.name}”:无法到达目标,标识符'obj'解析为空 错误错误。请帮我。 (玻璃鱼4.1)