JSF2 + Eclipse + Glassfish strange output problem
I try to make a simple JSF2 application in Eclipse indigo. I have a very simple ManagedBean (call HelloBean.java)
package server;
@ManagedBean
@RequestScoped
public class HelloBean {
private String name;
public HelloBean() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
And this is my index.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
开发者_JS百科<h:head><title>JSF 2.0 Hello World</title></h:head>
<h:form>
<h:inputText value="#{helloBean.name}"></h:inputText>
<h:commandButton value="Welcome me" action="welcome"></h:commandButton>
</h:form>
</html>
In eclipse I created an user library called JSF2.0 and added the jsf-api... and jsf-impl jars. In the projects setting I choosed JavaServer Faces. When I publish this really dummy app, and check a browser I see a totally blank page. Only the title is ok, but the rest of the content doesn't appears.
I checked the server log file, no warning no error, it looks ok.
What's the problem? Am I miss something important?
Thanks for the help!
Check that you have the Faces Servlet
in your web.xml
:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
Then make sure that your URL contains faces
prefix, like http://localhost:8080/faces/index.xhtml
.
精彩评论