在這個小小的項目中,只有一個類RichBean.java和一個JSF文件index.html來演示在JSF中使用CDI。我的問題是關於「爲什麼在JSF的web.xml中以這種方式定義?
<welcome-file>faces/index.xhtml</welcome-file>"
在web.xml中定義的。爲什麼是‘面孔/’?
沒有任何提及‘面孔/’目錄或配置。我覺得‘面孔’只是一個名字,可以是任何東西,但它不是這樣的。我試着將其更改爲別的東西,即「faceg」,它則不起作用。
RichBean.java
@Named
@SessionScoped
public class RichBean implements Serializable {
private String name;
@PostConstruct
public void postContruct() {
name = "John";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
index.xhtml
....
<body>
<ui:composition template="/templates/template.xhtml">
<ui:define name="title">Hello world JSF</ui:define>
<ui:define name="body">
<fieldset style="width:500px">
<legend>Helloworld using JSF and RichFaces</legend>
<p>
This example demonstrates adding ajax processing and updating to a standard JSF component.
</p>
<rich:panel header="Ajax enabled inputText">
<h:form id="helloWorldJsf">
<h:outputLabel value="Name:" for="nameInput"/>
<h:inputText id="nameInput" value="#{richBean.name}">
<a4j:ajax event="keyup" render="output"/>
</h:inputText>
<h:panelGroup id="output">
<h:outputText value="Hello #{richBean.name}!"
rendered="#{not empty richBean.name}"/>
</h:panelGroup>
</h:form>
</rich:panel>
</fieldset>
</ui:define>
</ui:composition>
</body>
</html>
的beans.xml
<beans xmlns="http://java.sun.com/xml/ns/javaee"
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/beans_1_0.xsd">
</beans>
web.xml中。
如何配置「faces /」?我不知道如何以及爲什麼它連接到項目中的其他任何東西。
我正在學習這個演示。請幫助理解這一點。非常感謝。
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
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- app_3_0.xsd">
<!-- add a welcome-file-list entry to allow JSF pages to be used as welcome files -->
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
爲什麼你使用不同的web.xml作爲例子,這與我給出的截然不同。所以你沒有用你的例子很好地解釋這個問題。請使用我的web.xml來解釋。謝謝。 – marlon 2014-09-30 04:00:05