Javaweb 之使用 Kaptcha 组件使用验证码
web.xml:
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi: schemalocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id = "webApp_id" = "3.0">>>> <Verlet-name> kaptcha </servlet-name> <Servlet-class> com.google.code.kaptcha.servlet.kaptchaservlet </servlet-class> </servlet> <ar Servlet-Mapping> <vlandomcode> kaptcha </servlet> <url-pattern> /Randomcode.jame.jame.jame.jame.jame.jame.jame.jame.jame.jame.jame.jame> <lorde-file-list> <lmed-File> index.html </-Welcome-File> <ldenmy-File> index.htm </limk-File> <lmed-File> index.jsp </limk-File> <lorde-file> padrão <lide-File> </-Weld-File> <lmed-File> default.htm </welcome> <lorde> </list-list> </web-App>
index.jsp:
<%@ Page Language = "java" import = "java.util. request.getscheme ()+": //"+request.getServername ()+":"+request.getServerport ()+path+"/";%> <! Doctype html public "-// w3c // dtd html 4.01 transitional // en en non 'Index.jsp' página de partida </itit> <meta http-equiv = "Pragma" content = "no-cache"> <meta http-equiv = "cache-control" content = "no-cache"> <meta http-mequiv = "expires" content = "0"> <meta http-alpela <meta http-equiv = "description" content = "Esta é a minha página"> <!-<link rel = "stylesheet" type = "text/css" href = "styles.css">-> </head> <body> <formulário action = "check.jsp"> <img src = "aleatomcode.jpg"> type = "submeter"/> </morm> </body> </html>
check.jsp:
<%@ Page Language = "java" import = "java.util. String str = request.getParameter ("r"); if (k.Equals (str)) out.print ("true"); out.print (""+k+"---"+str);%>结果
验证码部分属性修改说明
以上就是本文的全部内容 , 希望对大家的学习有所帮助 , 也希望大家多多支持武林网。