1

I want to use BotDetect Catpcha in my SpringBoot application but unfortunately BotDetect requires me to make Captcha Definitions at web.xml. But I do not have web.xml. Do you think is it possible to make servlet definitions at SpringBoot without using web.xml ?

web.xml Sample :

   <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>
Tonyukuk
  • 5,745
  • 7
  • 35
  • 63
  • I suggest a read of the [reference documentation](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-embedded-container-servlets-filters-listeners-beans). the `web.xml` is just a means to an end, in this case registration of a servlet. The only requirement here is that you register the servlet how you do that doesn't matter. – M. Deinum Jun 20 '17 at 08:44

1 Answers1

1
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(new CaptchaServlet());
    registration.setUrlMappings(Arrays.asList("/botdetectcaptcha"));
    return registration;
}

SpringBoot Application Class

genius
  • 24
  • 3