Validator-Filter the submitted user name and password

Source: Internet
Author: User

Learning slag to take notes, learn to take notes ~ ~ ~

The validator is divided into three parts, which are added on a well-done login interface.

1. Add in the. JSP, where the s tag is added, it is important not to forget <% @taglib prefix= "s" uri= "/struts-tags"%>

1<tr>2<td>&nbsp;</td>3&LT;TD width= "11%" height= "Nine" > Username:&nbsp;&nbsp;</td>4&LT;TD height= "colspan=" 2 ">5<input type= "text" size= "border=" 1 "name=" Infor.name ">6<s:property value= "fielderrors[' Infor.name '][0]"/>7</td>8</tr>9<tr>Ten<td>&nbsp;</td> One&LT;TD width= "11%" height= "> Password /images/luck.gif "width=" 19 " height= ">:&nbsp;&"nbsp; A</td> -&LT;TD height= "colspan=" 2 "><input type=" text "size=" border= "1" name= "Infor.password" > -<s:property value= "fielderrors[' Infor.password '][0]"/> the</td> -</tr>
View Code

2. Write verification information in X-x-validation.xml

1<?xml version= "1.0" encoding= "UTF-8"?>2<!DOCTYPE validators Public3"-//opensymphony group//xwork Validator 1.0.3//en"4"Http://www.opensymphony.com/xwork/xwork-validator-1.0.3.dtd" >//What version is written ?5<validators>6<field name= "Infor.name" >7<field-validator type= "Requiredstring" >8<message> user name cannot be empty </message>9</field-validator>Ten<field-validator type= "Stringlength" > One<param name= "MinLength" >2</param> A<param name= "MaxLength" >12</param> -<message> -Account length must be in ${minlength}~between ${maxlength} the</message> -</field-validator> -</field> -          +<field name= "Infor.password" > -<field-validator type= "Requiredstring" > +<message> password cannot be empty </message> A</field-validator> at<field-validator type= "Stringlength" > -<param name= "MinLength" >3</param> -<param name= "MaxLength" >12</param> -<message> -Password length must be in ${minlength}~between ${maxlength} -</message> in</field-validator> -</field> to</validators>
View Code

3~. The default execute () {} method used in the Java file is to add the input jump interface directly to the Struts.xml

1     class= "Com.chinasofti.strutshuman.struts.Landing" >2         <result name= "Havelervel1" type= "Dispatcher" >/massage.jsp</result>3         <result name= "Havelervel2" type= "Dispatcher" >/ Massage.jsp</result>4         <result name= "Havelervel3" type= "Dispatcher" >/massage.jsp</ Result>5         <result name= "Havepassword" type= "Dispatcher" >/massage.jsp</result>6          <result name= "input" type= "dispatcher" >/landing.jsp</result>7     </ Action>
View Code

Validator-Filter the submitted user name and password

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.