引入并学习kaptcha验证码工具库
本节学习MAVEN仓库中的开源Jar包,Kaptcha验证码工具库。
配置Kaptcha工具库Servlet服务
在MVN仓库中搜索com.github.penggle,就可以找到Kaptcha工具库,将它的dependency直接复制到pom.xml中,Maven会自动下载这个工具库。
pom.xml
<!--验证码处理-->
<!-- https://mvnrepository.com/artifact/com.github.penggle/kaptcha -->
<dependency>
<groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
<version>2.3.2</version>
</dependency>
然后,需要在web.xml中写入servlet服务。
web.xml
<servlet>
<servlet-name>Kaptcha</servlet-name>
<servlet-class>com.google.code.kaptcha.servlet.KaptchaServlet</servlet-class>
<!--是否有