Ich versuche gerade das hello1 example aus dem javaee6 Tutorial zu deployen.
Ich habe folgende Klassen:
Hello.java:
index.xhtml:
response.xhtml:
web.xml:
Die OrdnerStruktur sieht so aus:
/
/JavaResources/src/hello1/Hello.java
/WebContent/WEB-INF/web.xml
/WebContent/index.xhtml
/WebContent/response.xhtml
BuildPath:
javax.faces.jar
Ich habe das ganze unter Eclipse als .war exportiert und dann unter glassfish deployed.
Leider wird nur das reine HTML angezeigt. Die jsf Tags werden ignoriert. Kann mir jemand sagen, was ich falsch mache?
Ich habe folgende Klassen:
Hello.java:
Code:
package hello1;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class Hello {
private String name;
public Hello() {
}
public String getName() {
return name;
}
public void setName(String user_name) {
this.name = user_name;
}
}
index.xhtml:
Code:
<?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 lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelets Hello Greeting</title>
</h:head>
<h:body>
<h:form>
<h:graphicImage url="duke.waving.gif" alt="Duke waving his hand"/>
<h2>Hello, my name is Duke. What’s yours?</h2>
<h:inputText id="username"
title="My name is: "
value="#{hello.name}"
required="true"
requiredMessage="Error: A name is required."
maxlength="25" />
<p></p>
<h:commandButton id="submit" value="Submit" action="response">
</h:commandButton>
<h:commandButton id="reset" value="Reset" type="reset">
</h:commandButton>
</h:form>
</h:body>
</html>
response.xhtml:
Code:
<?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 lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelets Hello Response</title>
</h:head>
<h:body>
<h:form>
<h:graphicImage url="duke.waving.gif" alt="Duke waving his hand"/>
<h2>Hello, #{hello.name}!</h2>
<p></p>
<h:commandButton id="back" value="Back" action="index" />
</h:form>
</h:body>
</html>
web.xml:
Code:
<web-app xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>Hello1JSF</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener></web-app>
Die OrdnerStruktur sieht so aus:
/
/JavaResources/src/hello1/Hello.java
/WebContent/WEB-INF/web.xml
/WebContent/index.xhtml
/WebContent/response.xhtml
BuildPath:
javax.faces.jar
Ich habe das ganze unter Eclipse als .war exportiert und dann unter glassfish deployed.
Leider wird nur das reine HTML angezeigt. Die jsf Tags werden ignoriert. Kann mir jemand sagen, was ich falsch mache?