I'm creating a Web Application with Maven in Eclipse. When I deploy its war-file to my local tomcat the JSF content doesn't show up in the browser. This is my home.xhtml file:
<!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">
<h:head>
<title>JSF Test</title>
</h:head>
<h:body>
<h3>Test</h3>
#{helloWorld.message}
</h:body>
</html>
Only the header shows up in the browser. The page source shows this:
<!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"><head>
<title>JSF Test</title></head><body>
<h3>Test</h3>
</body>
</html>
I'm accessing localhost:8080/test/home.xhtml
, the mapping for .xhtml
is enabled:
<servlet-mapping>
<servlet-name>facesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
This is the HelloWorld class:
package com.tutorialspoint.test;
import javax.faces.bean.ManagedBean;
@ManagedBean(name = "helloWorld", eager = true)
public class HelloWorld {
public HelloWorld() {
System.out.println("HelloWorld started!");
}
public String getMessage() {
return "Hello World!";
}
}
The page is obviously being processed, otherwise the #{helloWorld.message}
command would show up in the page source code and the browser would render it as plain text. So what could be the problem? Thanks!