Javaweb
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/nns/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 <Servlet-Name> Kaptcha </servlet-name> <servlet-class> com.google.code.kaptcha.servlet.kaptchaservlet </servlet-class> </servlet-mapping> <servlet-name> kaptcha </servet-name> <url-pattern> </url-pattern> <welcome-file-list> <welcome-file> index.html </welcome-file> <welcome-file> index.htm </welcome-file> <welcome-file> index.jsp </welcome-file> <welcome-file> default.html </welcome-file> <welcome-file> default.HTM
index.jsp:
<%@ page Language = "Java" Import = "Java.util。*" contentType = "text/html; charset = utf-8"%> <%string path = request.getContextPath = request.getScheme()+"://"+request.getServername()+" html public " - // w3c // dtd html 4.01 transitional // en"> <html> <head> <base href = "<%= basepath%>"> <title> my jsp 'index.jsp'開始ページ</title> <meta http-equiv = "Pragma" content = "no-cache"> <meta http-equiv = "compers" content = "0"> <meta http-equiv = "keywords" content = "keyword1、keyword2、keyword3"> <meta http-equiv = "description" content = "this is my page"> <! href = "styles.css"> - > </head> <body> <form action = "check.jsp"> <img src = "randomcode.jpg"> <入力タイプ= "テキスト" name = "r"/> <入力タイプ= "submit"/> </form> </body> </html> </html> <入力タイプ=
check.jsp:
<%@ page Language = "Java" Import = "Java.util。*" contentType = "text/html; charset = utf-8"%> <%// string str = request.getParameter( "r"); if(k.equals(str))out.print( "true"); out.print( ""+k+"---"+str);%>
结果:
验证码部分属性修改说明:
以上就是本文的全部内容、希望对大家的学习有所帮助、也希望大家多多支持武林网。