Added textbox using JSF tags but NOT visible on the screen
I have a Facelet file with JSF tags to display a label, an input field and a button, but those parts are are not visible in the browser when I run it.
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!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:h="http://java.sun.com/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title> supply a title</title>
</h:head>
<h:body>
<h:form>
Name:
<h:outputLabel value="First Name:"> </h:outputLabel>
<h:inputText id="name" value="#{DataForm.name}"></h:inputText>
<h:commandButton value="Doctor Register" action="#{DataForm.submit}"> </h:commandButton>
</h:form>
</h:body>
</html>
How is this caused and how can I solve it? I am using netbeans 6.9.1 Glassfish 3.1.
This can happen when the FacesServlet
is not been invoked. It's the one responsible for parsing the Facelet file and doing all the JSF works.
You need to ensure that your request URL (the one which you see in the browser address bar) matches the URL pattern of the FacesServlet
as it is been mapped in the web.xml
. If it's for example mapped on an URL pattern of *.jsf
, then you need to ensure that you open the page in browser by
http://localhost:8080/contextname/index.jsf
Or when you want to invoke the FacesServlet
on every *.xhtml
request, then you need to change the URL pattern of the mapping in web.xml
accordingly (recommended)
<url-pattern>*.xhtml</url-pattern>
精彩评论