我試圖做一個簡單的JSF的Hello World,用JSF 2.0的JBoss AS 7.0 這是我的XHML文件:豆或財產類不能被發現
<!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://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Page 1</title>
</h:head>
<body>
<f:view>
<h:outputLabel value="Hello Stock Manager Hello JSF again" />
<br/>
<h:outputLabel value="Tester Bean : #{testerBean.message}" />
</f:view>
</body>
</html>
和這裏的託管bean類:
package prv.stockmanager.web.beans;
public class TesterBean {
private String message = "This is a message";
public TesterBean() {
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
而這裏的面孔,配置(這是在WEB-INF):
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<managed-bean>
<managed-bean-name>testerBean</managed-bean-name>
<managed-bean-class>prv.stockmanager.web.beans.TesterBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property> <property-name>message</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
</managed-bean>
</faces-config>
如果我刪除對託管bean的調用,該頁面可正常工作。但是當我打電話給託管bean時,我得到:
無法找到託管bean testerBean的Bean或屬性類prv.stockmanager.web.beans.TesterBean。 at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:265)[jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT] at com.sun.faces .el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)[jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
是因爲JBoss AS 7.0使用JSF 2.1 jar文件什麼的?我應該使用JSF 2.1嗎?如何改變?