Spring mvc 有一种在Stringboot项目中使用BotDetect验证码的方法吗?
我想在我的SpringBoot应用程序中使用BotDetect Catpcha,但不幸的是,BotDetect要求我在web.xml上定义Captcha。但是我没有web.xml。您认为在SpringBoot上创建servlet定义而不使用web.xml有可能吗 web.xml示例:Spring mvc 有一种在Stringboot项目中使用BotDetect验证码的方法吗?,spring-mvc,spring-boot,botdetect,Spring Mvc,Spring Boot,Botdetect,我想在我的SpringBoot应用程序中使用BotDetect Catpcha,但不幸的是,BotDetect要求我在web.xml上定义Captcha。但是我没有web.xml。您认为在SpringBoot上创建servlet定义而不使用web.xml有可能吗 web.xml示例: <servlet> <servlet-name>BotDetect Captcha</servlet-name> <servlet class
<servlet>
<servlet-name>BotDetect Captcha</servlet-name>
<servlet class>com.captcha.botdetect.web.servlet.CaptchaServlet</servlet-
class>
</servlet>
<servlet-mapping>
<servlet-name>BotDetect Captcha</servlet-name>
<url-pattern>/botdetectcaptcha</url-pattern>
</servlet-mapping>
检测验证码
com.captcha.botdetect.web.servlet.CaptchaServlet
检测验证码
/Bottcaptcha
SpringBoot应用程序类我建议阅读。web.xml
只是达到目的的一种手段,在本例中是注册servlet。这里唯一的要求是注册servlet,不管如何注册。
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new CaptchaServlet());
registration.setUrlMappings(Arrays.asList("/botdetectcaptcha"));
return registration;
}