读书人

JSF2简略验证-JSF2 学习笔记2

发布时间: 2012-09-01 09:33:02 作者: rapoo

JSF2简单验证------JSF2 学习笔记2

1.准备工作 如 一个简单的jsf例子------JSF2学习笔记1<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <f:view> <head> <title>index</title> </head> <body> <h:form> <h3>Please enter your name and password.</h3> <table> <tr> <td>Name:</td> <td> <h:inputText value="#{user.name}" required="true" id="name" requiredMessage="请输入用户名"/> <span style="color: red">*</span> <h:message for="name"></h:message> </td> </tr> <tr> <td>Password:</td> <td> <h:inputSecret value="#{user.password}" required="true" id="password" requiredMessage="请输入密码"/> <span style="color: red">*</span> <h:message for="password"></h:message> </td> </tr> </table> <p> <h:commandButton value="Login" action="login"/> </p> </h:form> </body> </f:view></html>

?

3.JSF的标准验证器

?

f:validateLongRange

<h:inputText value="#{userRegister.age }"  required="true" id="Age"><f:validateLongRange minimum="1" maximum="150"></f:validateLongRange><!-- 年龄在1到150之间 --></h:inputText><h:message for="Age"></h:message>

?

f:validateDoubleRange

<h:inputText value="#{userRegister.height }" required="true" id="Height"><f:validateDoubleRange minimum="75.00" maximum="250.00"></f:validateDoubleRange></h:inputText><h:message for="Height"></h:message>

?

?

读书人网 >JavaScript

热点推荐