0
我試圖創建一個表單,其中FirstName是要提交表單所需的字段(要添加其他驗證一次可以找出什麼不對的錯誤):JSF - 「在XHTML表單上沒有標籤名稱:validateRequired」錯誤
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" lang="en"
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">
<h:head>
<title>Register as a Voter</title>
</h:head>
<h:body>
Please fill out all information below to register as a voter.
<br/>
<h:form id = "form" >
<h:outputLabel value = "First Name:"/>
<h:inputText value = "#{voterBean.firstName}">
<h:validateRequired/>
</h:inputText>
<br/>
<h:outputLabel value = "Last Name:"/>
<h:inputText value = "#{voterBean.lastName}"/>
<br/>
<h:outputLabel value = "Address:"/>
<h:inputText value = "#{voterBean.address}"/>
<br/>
<h:outputLabel value = "City:"/>
<h:inputText value = "#{voterBean.city}"/>
<br/>
<h:outputLabel value = "State"/>
<h:inputText value = "#{voterBean.state}"/>
<br/>
<h:outputLabel value = "Zip:"/>
<h:inputText value = "#{voterBean.zip}"/>
<br/>
<h:outputLabel value = "Phone:"/>
<h:inputText value = "#{voterBean.phone}"/>
<br/>
<h:outputLabel value = "Affiliation:"/> <br/>
<h:selectOneRadio value="#{voterBean.affil}"><br/>
<f:selectItem itemValue="Democrat" itemLabel="Democrat" />
<f:selectItem itemValue="Green Party" itemLabel="Green Party" />
<f:selectItem itemValue="Liberterian" itemLabel="Liberterian" />
<f:selectItem itemValue="Republican" itemLabel="Republican" />
<f:selectItem itemValue="Unafilliated" itemLabel="Unafilliated" />
</h:selectOneRadio>
<br/>
<h:commandButton id = "Submit" value = "Submit" action = "Results"/>
</h:form>
</h:body>
</html>
然而,當我部署此代碼,並獲得這個XHTML文件我得到那個說
「/Register.xhtml @ 24,23標籤錯誤庫支持命名空間:http://java.sun.com/jsf/html,但沒有標籤被定義爲名稱:validateRequired「
我試過在stackoverflow上閱讀這個錯誤的解決方案,但我找不出什麼問題。
我相信我正確地做這個....