当前位置:首页 > 开发 > 编程语言 > Struts2 > 正文

Struts2对Action提交方法进行验证

发表于: 2014-07-21   作者:一代宗师   来源:转载   浏览:
摘要:     【Struts2】★☆之struts2对Action提交方法进行验证         在实际的开发项目中,我们通常采用的是js对我们输入的值进行验证,例如,用户名的长度,密码长度,等等。但是这样做,不好之处就是我们可以通过人为的将开发者的验证js注掉,这样就导致验证失败,对后台安全性是一个很大的威胁,

 

 

【Struts2】★☆之struts2对Action提交方法进行验证

 

 

    在实际的开发项目中,我们通常采用的是js对我们输入的值进行验证,例如,用户名的长度,密码长度,等等。但是这样做,不好之处就是我们可以通过人为的将开发者的验证js注掉,这样就导致验证失败,对后台安全性是一个很大的威胁,在采用struts2进行开发时,我们可以采用框架内置的校验器,对我们的Action进行校验。本文所讲诉的就是如何使用重写struts2中的ActionSupport里面的validate方法对输入值进行校验。

 

    ok,看下面代码!

 

1、搭建struts2开发环境-struts2开发环境

 

2、编写我们的Action方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package  csg.struts2.action;
 
import  java.util.regex.Pattern;
 
import  com.opensymphony.xwork2.ActionContext;
import  com.opensymphony.xwork2.ActionSupport;
 
/**
 
  * @author 小夜的传说
  * @2014-7-20
  * @validate
  * @csg.struts2.action
  * @StrutsAction
  * @2014-7-20下午7:21:26
  */
public  class  StrutsAction  extends  ActionSupport {
     private  static  final  long  serialVersionUID = 1L;
     private  String username;
     private  String mobile;
     public  String getUsername() {
         return  username;
     }
     public  void  setUsername(String username) {
         this .username = username;
     }
     public  String getMobile() {
         return  mobile;
     }
     public  void  setMobile(String mobile) {
         this .mobile = mobile;
     }
     
     public  String update(){
         ActionContext.getContext().put( "message" "更新成力sp;           }
     }
          code style="overflosavsible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important;colo; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclayle: normier New3, Courier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importvisible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !im3ot4a/s 006699 uom-right-radius: 0px; border-bottom-left-radius: 0px; border: 0px;" class="line number35 index34 alt2">           code st="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importalo; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: 10px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
          }
     }
p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">     /**overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclayle: nor4ier New4, Courier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importvisible !importantweieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java space" class="java plain">,  ndex26 alt2"> preprocerfor">*le="ov全局方法进行验证overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclayle: nor4ier New4ieCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importanolor: blue !important; font-style: normal !tant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java space" class="java plain">,  ndex26 alt2"> preprocerfor">*/overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclayle: nor4ier New4, Courier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importvisible !importantweieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0pxom-right-radius: 0px; border-bottom-left-radius: 0px; border: 0px;" class="line number35 index34 alt2"> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&n;text.getContext().put( comments">/*@Overrideoverflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclayle: nor4al !imp4rtant; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border: 0px; style="overflow: visible !importantweieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !imom: 0px !important;" class=" class="java plain">,  ndex26 alt2"> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !imom: 0px !important;" class=" class="java plain">,  comments">publicle="ovvoidle="ovvalidatsible="ov{overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclayle: nor4ier New4, Courier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importvisible !importantweieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0pxom-right-radius: 0px; border-bottom-left-radius: 0px; border: 0px;" class="line number35 index34 alt2"> comments">if(this.username==null||ible !ible !.equals(this.username.trim())){overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importano; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">     this.addFieldError(ible !usernameible !yle="ovible !用户名不能为空ible !="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importalo; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: 10px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
     yle="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: no; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
if(this.mobile==null||ible !ible !.equals(this.mobile.trim())){overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal mormal !impowhite-ndex2-rhtwrap; ont-weight: normal !important; font-s!important; font-stpadding-ine-heom-rivisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impopadding-p-rom-rivisible !impopadding-tant: rmal !important;x; border-bottom-left-radius: 0px; border: 0padding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number5ier New5ieCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importanolor: blue !important; font-style: normal !tant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java space" class="java plain">,  ndex26 alt2"> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !imom: 0px !important;" class=" class="java plain">,  comments">this.addFieldError(ible !mobileible !yle="ovible !手机号不能为空ible !="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-styl-ag none !important; fwhite-ndex2-rhtwrap; ont-weight: normal !important; font-s!important; font-stpadding-ine-heom-rivisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impopadding-p-rom-rivisible !impopadding-tant: rmal !important;x; border-bottom-left-radius: mvisible !impopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number5ier New5ieCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importanolor: blue !important; font-style: normal !tant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java space" class="java plain">,  ndex26 alt2"> comments">}else{overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importano; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
,  ndex26 alt2">      if(!Pattern.compile(ible !^1[358]\\d{9}$ible !=.matcher(this.mobile).matches()){overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importano; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
     this.addFieldError(ible !mobileible !yle="ovible !手机号格式不正确ible !="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !ig2-rhtlo; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: 10px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
     yle="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: no; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
,  ndex26 alt2"> comments">yle="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; fontimormal !impowhite-ndex2-rhtwrap; ont-weight: normal !important; font-s!important; font-stpadding-ine-heom-rivisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impopadding-p-rom-rivisible !impopadding-tant: rmal !important;x; border-bottom-left-radius: mvisible !impopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number5ier New5, Courier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importvisible !importantweieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0pxom-right-radius: 0px; border-bottom-left-radius: 0px; border: 0px;" class="line number35 index26 alt2"> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !imom: 0px !important;" class=" class="java plain">,  comments">super.validatsib;overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: normal !important;padding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number5ier New5ieCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importvisible !importantweieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0pxom-right-radius: 0px; border-bottom-left-radius: 0px; border: 0px;" class="line number35 index26 alt2"> p-r: 0px !important;" class=-p-r: border: 0px; paddinadius:ine-heyle="overflow: visible !important;tant;" class="java spaces">     y*/overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importano; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
     /**overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: normal !important;padding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number6ier New5, Courier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importvisible !importantweieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0pxom-right-radius: 0px; border-bottom-left-radius: 0px; border: 0px;" class="line number35 index26 alt2"> comments">*yle="o单个方法进行验证overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !important; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: normal !important;padding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number6ier New6ieCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importanolor: blue !important; font-style: normal !tant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java space" class="java plain">,  ndex26 alt2"> comments">*/overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importano; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number6ier New6ieCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importvisible !importantweieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java space" class="java plain">,  ndex26 alt2">      publicble !imyle="o ine-heytant-radlass="java strin" class="java plain">,  keywadi">voidble !imyle="o plain">validatsSave()yle="o{overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importano; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number6ier New6ieCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importanolor: blue !important; fhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java space" class="java plain">,  ndex26 alt2"> keywadi">ifble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; color: blue !important; fhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;"adiusom-right-radi" class="java plain">,  plain">(ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; color: blue !important; fboldvisible !impotext-al#006699visible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  keywadi">thisble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; color: blue !important; fhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  plain">.username==ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; color: blue !important; fboldvisible !impotext-al#006699visible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  keywadi">nullble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; color: blue !important; fhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  plain">||ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; color: blue !important; fhtrmalvisible !impotext-albluovisible !importantssize-rhtrmalvisible !impotext-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">     ible !ible !ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; color: blue !important; fhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" ciusom-right-radi" class="java plain">,  plain">.equals(ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; !olor: blue tant;weieft-rboldvisible !impotext-al#006699visible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  keywadi">thisble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importanlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;"adiusom-right-radi" class="java plain">,  plain">.username.trim())){overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importalo; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: 10px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
,  ndex26 alt2"> keywadi">thisble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: rier, monondex2visible !impovertical-align: baseline !olor: blue bt-ag none imormal !impoont-weight: normal !important; font-s!important; font-sttext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;"adiusom-right-radi" class="java plain">,  plain">.addFieldError(ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; !olor: blue tant;weieft-rhtrmalvisible !impotext-albluovisible !importantssize-rhtrmalvisible !impotext-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" clusom-right-radi" class="java plain">,  string">ible !usernameible !ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importhtlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; pai; /code> ine-heyrbord-radlass="java strin-ine-heytant-radlass="java strin" class="java plain">,  plain">,yle="oble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importhtlovisible !importantweieft-rhtrmalvisible !impotext-albluovisible !importantssize-rhtrmalvisible !impotext-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" clusom-right-radi" class="java plain">,  string">ible !用户名不能为空ible !ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importhtlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" ciusom-right-radi" class="java plain">,  plain">);overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importano; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number6ier New6ieCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importanolor: blue !important; fhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java space" class="java plain">,  ndex26 alt2"> plain">yle="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: no; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number6al !imp6ieCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importvisible !importantweieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0pxom-right-radi-ine-heytant-radlass="java strin" class="java plain">,  ndex26 alt2"> keywadi">ifble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important;visible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !impo:tant-radlass="java strin" class="java plain">,  plain">(ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; !olor: blue tant;weieft-rboldvisible !impotext-al#006699visible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  keywadi">thisble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importanlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padd badius:ine-heyle="overflow: visible !important;tant;" class="java spaces">     .mobize==ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; !olor: blue tant;weieft-rboldvisible !impotext-al#006699visible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; paddingrder-ine-heyrbord-radlass="java strin-ine-heytant-radlass="java strin" class="java plain">,  keywadi">nullble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal ont-weight: normal !important; font-shtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" ciusom-right-radi" class="java plain">,  plain">||ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important;visible !importantweieft-rhtrmalvisible !impotext-albluovisible !importantssize-rhtrmalvisible !impotext-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" clusom-right-radi" class="java plain">,  string">ible !ible !ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importhtlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; pai; /code> ine-heyrbord-radlass="java strin-ine-heytant-radlass="java strin" class="java plain">,  plain">.equals(ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !impo-rhtlovisible !importantweieft-rboldvisible !impotext-al#006699visible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  keywadi">thisble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: rier, monondex2visible !impovertical-align: baseline !olor: blue bt-ag none imormal !impoont-weight: normal !important; font-s!important; font-sttext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radiusrmal !important;width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">     .mobize.trim())){overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal mag2-rhtlo; white-ndex2-rhtwrap; ont-weight: normal !important; font-shtrmalvisible !impopadding-ine-heom-rivisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impopadding-p-rom-rivisible !impopadding-tant-rrmal !important;x; border-bottom-left-radius: 0px; border: 0padding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number67 index66eCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importa!olor: blue tant;weieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java space" class="java plain">,  ndex26 alt2"> keywadi">thisble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importanlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !impo:tant-radlass="java strin" class="java plain">,  plain">.addFieldError(ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal ont-weight: normal !important; font-shtrmalvisible !impotext-albluovisible !importantssize-rhtrmalvisible !impotext-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important-radlass="java strin" class="java plain">,  string">ible !mobizeible !ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importhtlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  plain">,yle="oble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal ont-weight: normal !important; font-shtrmalvisible !impotext-albluovisible !importantssize-rhtrmalvisible !impotext-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: iusom-right-radi-ine-heyrbord-radlass="java strin-ine-heytant-radlass="java strin" class="java plain">,  string">ible !手机号不能为空ible !ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: notlo; ont-weight: normal !important; font-shtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !impo:tant-radlass="java strin" class="java plain">,  plain">);overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importalo; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: 10px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
ndex26 alt2"> plain">yle="ove ine-heytant-radlass="java strin" class="java plain">,  keywadi">elseble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; color: blue !important; fhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding:der-ine-heyrbord-radlass="java strin-ine-heytant-radlass="java strin" class="java plain">,  plain">{overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importano; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number69 index68eCourier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importa!olor: blue tant;weieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  ndex26 alt2"> keywadi">ifble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important;visible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !impo:tant-radlass="java strin" class="java plain">,  plain">(!Pattern.compize(ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; !olor: blue tant;weieft-rhtrmalvisible !impotext-albluovisible !importantssize-rhtrmalvisible !impotext-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important-radlass="java strin" class="java plain">,  string">ible !^1[358]\\d{9}$ible !ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importhtlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; pai; /code> ine-heyrbord-radlass="java strin-ine-heytant-radlass="java strin" class="java plain">,  plain">).matcher(ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important;visible !importantweieft-rboldvisible !impotext-al#006699visible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  keywadi">thisble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal ont-weight: normal !important; font-shtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !impo:tant-radlass="java strin" class="java plain">,  plain">.mobize).matches()){overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importano; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number70 index69eCou1"> ndex26 alt2"> keywadi">thisble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importanlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padd badius:ine-heyle="overflow: visible !important;tant;" class="java spaces">     .addFieldError(ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal ont-weight: normal !important; font-shtrmalvisible !impotext-albluovisible !importantssize-rhtrmalvisible !impotext-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: iusom-right-radi-ine-heyrbord-radlass="java strin-ine-heytant-radlass="java strin" class="java plain">,  string">ible !mobizeible !ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !loat-rhtlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; pai; /code> ine-heyrbord-radlass="java strin-ine-heytant-radlass="java strin" class="java plain">,  plain">,yle="oble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !imporrhtlovisible !importantweieft-rhtrmalvisible !impotext-albluovisible !importantssize-rhtrmalvisible !impotext-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" clusom-right-radi" class="java plain">,  string">ible !手机号格式不正确ible !ble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !importhtlovisible !importantweieft-rhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; pai; /code> ine-heyrbord-radlass="java strin-ine-heytant-radlass="java strin" class="java plain">,  plain">);overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importalo; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: 10px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
,  ndex26 alt2"> plain">yle="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: no; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number72 index71eCou1"> ine-heytant-radlass="java strin" class="java plain">,  ndex26 alt2"> plain">yle="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: no; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number73 index72 Courier, monospace !important; vertical-align: baseline !important; background-image: none; white-space: nowrap; float: none !important; font-weight: normal !important; padding-bottom: 0px !important; font-style: normal !important; text-align: left !importa!olor: blue tant;weieft-rhtrmalvisible !impotant; width: auto !important; border-top-left-radius: 0px; bx; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px;m-ri; /code> ine-heytant-radlass="java strin" class="java plain">,  ndex26 alt2"> keywadi">superble !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: normal !important; color: blue !important; fhtrmalvisible !impotext-alblt-avisible !important-sizeightrmalvisible !impoflow-align: tantvisible !impox; border-bottom-left-radius: 0px; border: 0width: autovisible !impo/adius:p-r:tant-radlass="java strin-p-r: border: 0px; padding:der-ine-heyrbord-radlass="java strin-ine-heytant-radlass="java strin" class="java plain">,  plain">.validate();overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: nonnt; font-style: normal !importalo; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: 10px; border-bottom-left-radius: 0px; border: 0px; padding: 0px !important;" class="java plain">}
ine-heytant-radlass="java strin" class="java plain">,  ndex26 alt2"> plain">yle="overflow: visible !important; font-size: 1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; vertical-align: baseline !important; background-image: none; float: none !important; font-weight: no; text-align: left !important; margin: 0px; line-height: 1.1em !important; width: auto !important; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; bodclass="java sp er-font-style: n0px; border-bottopadding- bord: rmal !important;width: autovisible !impo/t-ag none text-alwhite; /code> p-r: 0px !important;" class=-p-r: border: 0px; padding: 0px !impor border: 0px; padding: 0px !important;" class="java spaces">&nb" class="line number75 index74 Courie plain">yle="ove

yle="o

yle="oyle="overflow: vis在这里讲解一下,我们的validate()方法会对我们Action里面的所有方法进行验证,但是比如说我们的get,list方法是不需要验证的所以通过validateXxx这样就可以对我们单个方法进行验证(validateXxx注意我们需要被验证的方法名首字母一定要大写)

yle="o

ok,

yle="o

3、编写我们的jsp提交页面(index.jsp)

,  syntaxhighlighter html">     
    
2
4
6
8
10
12
14
16
18
20
22
24
,  code">
,  html plain"><%@yle="opag2yle="olanguag2="java"yle="oolor: ="java.util.*"yle="opag2Encoding="utf-8"%>ble !important;
html plain"><%@taglibyle="oprefix="s"yle="ouri="/struts-tags"yle="o%>ble !important;
<!DOCTYPEyle="oHTMLyle="oPUBLICyle="ovquot;-//W3C//DTDyle="oHTMLyle="o4.01yle="oTransitional//EN"ygt;ble !important;
html plain"><ble !important;     htmlble !important; >ble !im
  ble !important; <ble !important; headble !important; html plain">>ble !im
    ble !important; html plain"><ble !important; titleble !important; >后台验证表单提交</ble !important; titleble !important; html plain">>ble !im
    ble !important; html plain"><ble !important; metable !im  http-equivble !important; =ble !important; &n; padding" cla !olor: blue" class="html string">"pragma"ble !im  cantentble !important; =ble !important; "no-cache"ble !important; >ble !im
    ble !important; <ble !important; metable !im  http-equivble !important; =ble !important; "cache-cantrol"ble !im  cantentble !important; =ble !important; "no-cache"ble !important; >ble !im
    ble !important; <ble !important; metable !im  http-equivble !important; =ble !important; "expires"ble !im  cantentble !important; =ble !important; "0"ble !important; >    ble !im
    ble !important; <ble !important; metable !im  http-equivble !important; =ble !important; "keywords"ble !im  cantentble !important; =ble !important; "keyword1,keyword2,keyword3"ble !important; >ble !im
    ble !important; <ble !important; metable !im  http-equivble !important; =ble !important; "description"ble !im  cantentble !important; =ble !important; "This is my pag2"ble !important; >ble !im
    ble !important; <!--ble !im
    ble !important; <link rel="-sizesheet" type="text/css" href="-sizes.css">ble !im
    ble !important; -->ble !im
  ble !important; </ble !important; headble !important; >ble !im
  ble !important; <ble !important; s:fielderrorble !important; />ble !im <!--获取验证失败之后的提示信息-->ble !im
  ble !important; <ble !important; bodyble !important; >ble !im
    ble !important; <ble !important; formble !im  actionble !important; =ble !important; "/validate/test/list_sav2"ble !im  methodble !important; =ble !important; "post"ble !important; >ble !im
        ble !important; 用户名:<ble !important; inputble !im  typeble !important; =ble !important; "text"ble !im  nameble !important; =ble !important; "username"ble !important; />不能为空<ble !important; brble !important; />ble !im
        ble !important; 手机号:<ble !important; inputble !im  typeble !important; =ble !important; "text"ble !im  nameble !important; =ble !important; "mobile"ble !important; />不能为空符合手机号格式<ble !important; brble !important; />ble !im
    ble !important; <ble !important; inputble !im  typeble !important; =ble !important; "submit"ble !im  valueble !important; =ble !important; "提交"ble !important; />ble !im
    ble !important; </ble !important; formble !im >ble !im
  ble !important; </ble !important; bodyble !important; >ble !im
</ble !important; htmlble !important; >ble !im

 

大家注意了,当我们验证成功之后,我的提示信息通过ActionContext.getContext()直接放在request范围里面,那么我们的验证失败之后的信息呢?这个就是放在ActionSupport里面这个属性中(看一下源码就知道了),ActionSupport里面有如下这段代码!

 

1
2
3
 ble !important; publicble !im  voidble !im  addFieldError(String fieldName, String errorMessage) {ble !im
        ble !important; validationAware.addFieldError(fieldName, errorMessage);ble !im
    ble !important; }ble !im

 

但是当我们验证失败之后,ActionSupport默认返回的是return "input"视图,所以我们需要在struts.xml中配置一项视图,如下

 

1
2
3
4
5
6
7
8
9
10
11
12
13
<?ble !important; xmlble !im  versionble !important; =ble !important; "1.0"ble !im  encodingble !important; =ble !important; "UTF-8"ble !im  ?>ble !im
<!DOCTYPE struts PUBLICble !important;
    ble !important; "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"ble !im
    ble !important; "http://struts.apache.org/dtds/struts-2.3.dtd">ble !im
 
<ble !important; strutsble !important; >ble !im
    ble !important; <ble !important; packageble !im  nameble !im =ble !important; "struts"ble !im  namespaceble !important; =ble !important; "/test"ble !im  extendsble !important; =ble !important; "struts-default"ble !im >ble !im
        ble !important; <ble !important; actionble !im  nameble !important; =ble !important; "list_*"ble !im  classble !important; =ble !important; "csg.struts2.action.StrutsAction"ble !im  methodble !important; =ble !important; "{1}"ble !im >ble !im
            ble !important; <ble !important; resultble !im  nameble !important; =ble !important; "success"ble !im >/WEB-INF/page/success.jsp</ble !important; resultble !im >ble !im
            ble !important; <ble !important; resultble !im  nameble !im =ble !important; "input"ble !im >/index.jsp</ble !important; resultble !im >ble !im
        ble !important; </ble !important; actionble !im >ble !im
    ble !important; </ble !important; packageble !important; >ble !im
</ble !important; strutsble !important; >ble !im

 blp>

那么在index.jsp中我们就可以直接通过struts标签来取到

this.addFieldError里面的值。

 blp>

ok,我们验证成功之后,直接转发到success.jsp页面,里面直接通过el表达式,${message}取到值

 blp>

源码下载:通过struts2中的validate()方法进行Action验证-源码

 blp>

 blp>

 blspan>

Struts2对Action提交方法进行验证

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
网上关于struts2 使用Validation框架进行数据验证的例子很多 这里不一一解释每个文件每行代码是什么
上一节介绍了struts2可以支持批量表单参数提交,那么提交到后台时如何利用strust2的validation框架
在实际开发项目中,一个Action类中可能包含多个处理逻辑的action方法,如果为每一个action方法去配
在Struts2中,Action处理完用户请求后,将会返回一个字符串对象,这个字符串对象就是一个逻辑视图名
在Struts2中,Action处理完用户请求后,将会返回一个字符串对象,这个字符串对象就是一个逻辑视图名
思路来源维基百科:http://en.wikipedia.org/wiki/Post/Redirect/Get 下图为传统POST传递方式: 下图
以前刚做java项目的时候,就用的是SSH框架,做了两个项目都用的是SSH框架,但是里面Action多个方法
源码地址:http://download.csdn.net/detail/biboheart/6024077 在web应用开发中,请求服务器返回js
有Index视图如下: 视图代码如下: [html] view plain copy <%@ Page Language="C#" MasterPageF
有Index视图如下: 视图代码如下: <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Sit
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号