2017-06-20 72 views
0

我想在我的SpringBoot应用程序中使用BotDetect Catpcha,但不幸的是BotDetect要求我在web.xml中创建Captcha定义。但我没有web.xml。你认为是否可以在不使用web.xml的情况下在SpringBoot中创建servlet定义?有一种方法可以在Stringboot项目中使用BotDetect验证码?

的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> 
+0

我建议[参考文档]的读出(https://docs.spring.io/spring-boot/文档/电流/参考/ HTML /启动功能 - 开发 - 网络applications.html#引导功能,嵌入式容器的Servlet过滤器 - 监听器 - 豆)。 'web.xml'只是达到目的的一种手段,在这种情况下,注册一个servlet。这里唯一的要求是你注册servlet的方式如何做并不重要。 –

回答

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

SpringBoot应用类

相关问题