1

我无法查看 InputText 框,我收到指示“未知标签(h:form)”的错误以及与 h:inputtext 类似的错误

主页.xhtml

<!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 Tutorial!</title>
</head>
<body>
   <h2>h:inputText example</h2>
   <hr />
   <h:form>
      <h3>Read-Only input text box</h3>
      <h:inputText value="Hello World!" readonly="true"/>
      <h3>Read-Only input text box</h3>
      <h:inputText value="Hello World"/>
   </h:form>
</body>
</html>

面孔-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
   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-facesconfig_2_0.xsd"
   version="2.0">
   <navigation-rule>
      <from-view-id>home.xhtml</from-view-id>

   </navigation-rule>   
</faces-config>

web.xml

   <web-app>
   <display-name>Archetype Created Web Application</display-name>

   <context-param>
      <param-name>javax.faces.PROJECT_STAGE</param-name>
      <param-value>Development</param-value>
   </context-param> 
   <context-param> 
      <param-name>javax.faces.CONFIG_FILES</param-name> 
      <param-value>/WEB-INF/faces-config.xml</param-value> 
   </context-param> 
   <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>*.xhtm</url-pattern>
   </servlet-mapping>
</web-app>

图书馆

jsf-api-2.1.7.jar jsf-impl-2.1.7.jar jstl-1.2.jar

4

2 回答 2

2

你有一个<url-pattern>*.xhtm</url-pattern>错字web.xml

您的页面是主页。xhtml,因此,Faces servlet 不处理它

于 2013-07-31T10:52:15.757 回答
1
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html">

替换上面代码的 HTML 开始标记 iwg。这应该可以解决问题。

于 2013-07-31T02:06:07.917 回答