@@ -40,8 +40,8 @@ public ValidateCode() {
40
40
}
41
41
42
42
private static final long serialVersionUID = -5813134629255375160L ;
43
- private int imagewidth = 100 ;
44
- private int imageheight = 35 ;
43
+ private int imageWidth = 100 ;
44
+ private int imageHeight = 35 ;
45
45
private int codeCount = 4 ;
46
46
private int fontHeight ;
47
47
private int codeY ;
@@ -58,35 +58,35 @@ public void init() throws ServletException {
58
58
String strCodeCount = this .getInitParameter ("codeCount" );
59
59
try {
60
60
if (strWidth != null && strWidth .length () != 0 ) {
61
- this .imagewidth = Integer .parseInt (strWidth );
61
+ this .imageWidth = Integer .parseInt (strWidth );
62
62
}
63
63
if (strHeight != null && strHeight .length () != 0 ) {
64
- this .imageheight = Integer .parseInt (strHeight );
64
+ this .imageHeight = Integer .parseInt (strHeight );
65
65
}
66
66
if (strCodeCount != null && strCodeCount .length () != 0 ) {
67
67
codeCount = Integer .parseInt (strCodeCount );
68
68
}
69
69
} catch (NumberFormatException e ) {
70
70
e .printStackTrace ();
71
71
}
72
- this .codeWidth = this .imagewidth / (codeCount + 1 );
73
- this .fontHeight = this .imageheight - 2 ;
74
- this .codeY = this .imageheight - 4 ;
72
+ this .codeWidth = this .imageWidth / (codeCount + 1 );
73
+ this .fontHeight = this .imageHeight - 2 ;
74
+ this .codeY = this .imageHeight - 4 ;
75
75
76
76
}
77
77
78
78
@ Override
79
79
protected void doGet (HttpServletRequest req , HttpServletResponse resp )
80
80
throws ServletException , IOException {
81
- BufferedImage buffImg = new BufferedImage (this .imagewidth ,
82
- this .imageheight , BufferedImage .TYPE_INT_RGB );
81
+ BufferedImage buffImg = new BufferedImage (this .imageWidth ,
82
+ this .imageHeight , BufferedImage .TYPE_INT_RGB );
83
83
Graphics2D gd = buffImg .createGraphics ();
84
84
Random random = new Random ();
85
85
gd .setColor (Color .white );
86
- gd .fillRect (0 , 0 , this .imagewidth , this .imageheight );
86
+ gd .fillRect (0 , 0 , this .imageWidth , this .imageHeight );
87
87
Font font = new Font ("Fixedsys" , Font .PLAIN , fontHeight );
88
88
gd .setFont (font );
89
- gd .drawRect (0 , 0 , this .imagewidth - 1 , this .imageheight - 1 );
89
+ gd .drawRect (0 , 0 , this .imageWidth - 1 , this .imageHeight - 1 );
90
90
91
91
StringBuilder randomCode = new StringBuilder ();
92
92
int red = 0 , green = 0 , blue = 0 ;
@@ -118,7 +118,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
118
118
throws IOException {
119
119
if (req .getParameter (Constant .VALIDATE_CODE ) != null
120
120
&& req .getParameter (Constant .VALIDATE_CODE ).equalsIgnoreCase (req .getSession ().getAttribute (
121
- Constant .VALIDATE_CODE )
121
+ Constant .VALIDATE_CODE )
122
122
.toString ().toLowerCase ())) {
123
123
resp .getWriter ().write ("OK" );
124
124
return ;
0 commit comments