javaweb之使用kaptcha组件使用验证码
web.xml:
<?xml版本=“ 1.0”编码=“ utf-8”?> <web-app xmlns:xsi =“ http://www.w.org/2001/xmlschema-chema-chema-instance” xmlns“ xmlns =” XSI:schemalocation =“ http://java.sun.com/xml/ns/javaee http://java.sun.com./xml/xml/ns/ns/javaee/javaee/web-app_3_3_3_3_3_3_3_3_3_3_3_3_3_3_3_3_3_3_3_3_3_3.3.3.0 wertled> <servlet-name> kaptcha </servlet-name> <servlet-class> com.google.code.kaptcha.servlet.kaptchaservlet </servlet-class> </servlet> </servlet> <servlet-mapply> <servlet-mapping> <servlet-name> <servlet-name> <servlet-name> <welcome-file-list> <welcome-file> index.html </welcy-file> <welcome-file> index.htm </welcy-file> <welclome-file> index.jsp </welcy-file> <welclion-file> <welclion-file> default.html </welcy-file> westair-file> <welction-file> default-file> default-file> default.htm </westai </welcome-file-list> </web-app>
index.jsp:
<%@ page语言=“ java” import =“ java.util。 html公共“ - // W3C // DTD HTML 4.01过渡// en”> <html> <head> <head> <base href =“ <%= basepath%>”> <tittle>我的JSP'Index.jsp.jsp'起始页</title> </title> </title> http-equiv =“ cache-control” content =“ no-cache”> <meta http-equiv =“ expir expires” content =“ 0”> <meta http-equiv =“键words” content =“键word1,键 - type =“ text/css” href =“ styles.css”> - > </head> <body> <form> <form action =“ check.jsp”> <img src =“ anduncode.jpg”> <input> <input type type =“ text” text =“ text” name =“ r”/>
check.jsp:
<%@ page语言=“ java” import =“ java.util。字符串str = request.getParameter(“ r”); if(k.equals(str))out.print(“ true”); out.print(“”+k+“ ---”+str);%>
结果:
验证码部分属性修改说明:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持武林网。,也希望大家多多支持武林网。