【问题标题】:there is a way to use BotDetect Captcha at Stringboot projecT ?有一种方法可以在 Stringboot 项目中使用 BotDetect Captcha 吗?
【发布时间】:2017-06-20 08:25:18
【问题描述】:

我想在我的 SpringBoot 应用程序中使用 BotDetect Catpcha,但不幸的是,BotDetect 要求我在 web.xml 中进行验证码定义。但我没有 web.xml。您认为是否可以在 SpringBoot 不使用 web.xml 的情况下进行 servlet 定义?

web.xml 示例:

   <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>

【问题讨论】:

  • 我建议阅读reference documentationweb.xml 只是达到目的的一种手段,在这种情况下是一个 servlet 的注册。这里唯一的要求是您注册 servlet 的方式并不重要。

标签: spring-mvc spring-boot botdetect


【解决方案1】:
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(new CaptchaServlet());
    registration.setUrlMappings(Arrays.asList("/botdetectcaptcha"));
    return registration;
}

SpringBoot 应用类

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-04
    • 2018-09-17
    • 1970-01-01
    • 2020-09-07
    • 2019-03-19
    • 2014-10-11
    • 2017-08-12
    • 1970-01-01
    相关资源
    最近更新 更多