在这个小小的项目中,只有一个类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