校验验证码是否正确的页面一片空白,无法显示校验结果true
check.jsp
<%--
Created by IntelliJ IDEA.
User: ASUS
Date: 2019/9/11
Time: 14:53
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>校验页</title>
</head>
<body>
<%
String k = (String)session.getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
String str = request.getParameter("r");
if(k.equals(str)){
System.out.println("true");
System.out.println(k+"..."+str);
}
%>
</body>
</html>index.jsp
<%-- Created by IntelliJ IDEA. User: ASUS Date: 2019/9/11 Time: 14:42 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>验证码</title> </head> <body> <form action="/check.jsp" method="post"> <img src="/randomcode.jpg"> <input type="text" name="r"> <input type="submit"> </form> </body> </html>
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <servlet> <servlet-name>kaptcha</servlet-name> <servlet-class>com.google.code.kaptcha.servlet.KaptchaServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>kaptcha</servlet-name> <url-pattern>/randomcode.jpg</url-pattern> </servlet-mapping> </web-app>
上一层楼的图错了,请看当前这张
运行结果截图