einfache JSF-Seite wird nicht angezeigt

lieschen89

Aktives Mitglied
Hi,

ich habe eine .xhtml Datei mit einem simplen outputText drin, was allerdings nicht angezeigt wird. Sieht folgendermaßen aus:

HTML:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:f="http://java.sun.com/jsf/core"
		xmlns:h="http://java.sun.com/jsf/html"
		xmlns:ui="http://java.sun.com/jsf/facelets">

<head>
	<title>header</title>
</head>
<body>
	<h1>Hallo</h1>
		<h:form id="Form">
				 <h:outputText value=" test "/>
		</h:form>
	<h1>Ende</h1>
</body>
</html>

Das "Hallo" und das "Ende" werden angezeigt im Browser, aber das wars dann auch.
Hatte auch versucht commandbuttons einzusetzen, aber das wird alles nicht angezeigt.

(Benutze Tomcat 7.0.25 und das log zeigt keine Warnungen)

Kann mir vielleicht jemand weiterhelfen?
 
Versuch mal sowas:

[xml]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 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:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title><h😱utputText value="#{msg['application.name']}" /></title>
<link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.request.contextPath}/css/layout.css" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="CacheControl" content="no-cache" />
<meta http-equiv="CacheControl" content="no-store" />
<meta http-equiv="CacheControl" content="must-revalidate" />
<meta http-equiv="CacheControl" content="private" />
<meta http-equiv="CacheControl" content="max-stale=0" />
<meta http-equiv="CacheControl" content="post-check=0" />
<meta http-equiv="CacheControl" content="pre-check=0" />
<meta http-equiv="Content-Type" content="application/xhtml+xml;charset=utf-8" />
</h:head>

<h:body>
<f:view>
<h:form id="Form">
<h😱utputText value=" test "/>
</h:form>
</f:view>
</h:body>
</html>[/xml]

Den Head-Bereich brauchst Du natürlich nicht übernehmen bzw. musst ihn anpassen. Aber eine View benötigst Du schon. 🙂
 
hast du in deiner Web.xml auch einen Eintrag der ungefähr so ausschaut?
[xml]
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!---snipp-->
<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>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- schnapp -->
</web-app>
[/xml]
 
Meine web.xml sieht so aus:

[XML]
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>MyPetStore Application</display-name>
<description>
MyPetStore application.
</description>

<!-- JavaServer Faces -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>

<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
</context-param>

<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>

<filter>
<filter-name>SecurityFilter</filter-name>
<filter-class>mypetstore.view.util.SecurityFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>SecurityFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>

<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- Tiles Servlet -->
<servlet>
<servlet-name>Tiles Servlet</servlet-name>
<servlet-class>org.apache.struts.tiles.TilesServlet</servlet-class>
<init-param>
<param-name>definitions-config</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>

[/XML]


Wenn ich das hier:
<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">


so einfüge unterkringelt er es rot

[XML]
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<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">
<display-name>MyPetStore Application</display-name>
<description>
MyPetStore application.
</description>

<!-- JavaServer Faces -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>

<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
</context-param>

<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>

<filter>
<filter-name>SecurityFilter</filter-name>
<filter-class>mypetstore.view.util.SecurityFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>SecurityFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>

<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- Tiles Servlet -->
<servlet>
<servlet-name>Tiles Servlet</servlet-name>
<servlet-class>org.apache.struts.tiles.TilesServlet</servlet-class>
<init-param>
<param-name>definitions-config</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>

[/XML]
 
ok, die Fehlermeldung hab ich wegbekommen indem ich einfach bei mir den "<!DOCTYPE ...." weggelassen habe.

allerdings bekomm ich, wenn ich folgenden Code in meiner web.xml drin lasse gar keine Seite mehr angezeigt, also weder mit .xhtml noch .jsf:

[XML]
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
[/XML]

(Fehler: The requested resource is not available.)
 
ok, hab den Fehler:

in der web.xml hatte ein context-Parameter gefehlt:

[XML]
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
[/XML]
 

Zurück
Oben