300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 登录页面显示不了验证码

登录页面显示不了验证码

时间:2018-12-25 20:23:17

相关推荐

登录页面显示不了验证码

用的是eclipse的JavaEE版本做的

出现的图片

在浏览器中显示不出来

验证的servlet 代码

public VerificationCodeServlet() {super();}protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setContentType("image/jpge");response.setHeader("Pragma","No-cache");response.setHeader("Cache-Control", "No-cache");response.setDateHeader("Expires", -1);OutputStream out = response.getOutputStream();int width=80,height=20;//定义画布对象 bufferedimage画布BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);//返回画布对象Graphics g = image.getGraphics();//定义随机数Random random = new Random();g.setColor(Color.gray);//用预设的颜色填充一个矩形 fill填充 fillrect填充矩形g.fillRect(0, 0, width, height);String sRand = "";for(int i=0;i<4;i++){//生出0-9的随机数String rand = String.valueOf(random.nextInt(10));sRand+=rand;g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110) ));g.drawString(rand, 20*i+6, 16);}g.dispose();ImageIO.write(image,"JPGE",response.getOutputStream());}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doGet(request, response);}

登录页面代码

<tr> <td ><font size="+4"><b>Hotel登录</b></font></td> </tr> <br><tr> <td ><font size="4px">用户名:</td> <td ><input id="userName" type="text" style="width:140px;height:22px;"></td></tr><br><tr> <td ><font color="dodgerblue"><font size="4px">密码:</td> <td ><input id="password" type="password" style="width:140px;height:22px;"></td> </tr> <br><tr><td ><font color="dodgerblue"><font size="4px">验证码:</td><td><input type="text" name="verification" style="width:140px;height:22px;"></td><td><img alt="" src="VerificationCodeServlet"></td></tr><br><tr > <td > <font color="dodgerblue">注册|忘记密码?</tr> <br><tr><td ><input type="submit" value="登 录" style="height: 35px; width:90px ;color:#FFFFFF;font-size: 16px;border-radius: 15%;background-color: #6495ED;"/> &nbsp;&nbsp;&nbsp;<input type="reset" value="重置" style="height: 35px; width:90px ;color:#FFFFFF;font-size: 16px;border-radius: 15%;background-color: #6495ED;"/></td></tr></table>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。