RequestContextListener
全部标签 我有一个单例springbean,它被调用以响应某些客户端操作。我希望捕获有关客户端的一些信息(特别是IP地址)。我假设此信息的最佳来源是请求对象。我如何从我的bean中获取对请求对象的访问权?如果这是一个显而易见的问题,请原谅我,我是Spring的新手。我试过一件事没有成功。:((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest().getRemoteAddr();但是由于currentRequestAttributes中的IllegalStateException
我正在开发一个javaspringmvc应用程序。我已经像这样实现了UserDetailsService接口(interface):@Component@TransactionalpublicclassSecurityDAOimplementsUserDetailsService{@OverridepublicUserDetailsloadUserByUsername(finalStringusername)throwsUsernameNotFoundException{...}....}我需要在loadUserByUsername方法中找到用户登录url(因为该项目有多个登录ur
好吧,我正尝试在tomcat中运行我的Web应用程序,但出现以下错误:Nov18,201312:19:35AMorg.apache.catalina.core.StandardContextlistenerStartGrave:Errorconfiguringapplicationlistenerofclassorg.springframework.web.context.request.RequestContextListenerjava.lang.ClassNotFoundException:org.springframework.web.context.request.Reque
我需要为我的SpringBoot应用程序添加一个监听器,在web.xml中它看起来像org.springframework.web.context.request.RequestContextListener我使用no-web.xml配置,所以我有一个类似的类publicclassAppFilterConfigextendsAbstractAnnotationConfigDispatcherServletInitializer{@OverrideprotectedFilter[]getServletFilters(){CharacterEncodingFilterfilter=newC
我有一个Web应用程序,它在一个单独的线程中运行了一个SpringIntegration逻辑。问题是在某些时候我的SpringIntegration逻辑尝试使用请求范围的bean,然后我得到以下错误:Causedby:org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'scopedTarget.tenantContext':Scope'request'isnotactiveforthecurrentthread;considerdefiningascopedproxyfort
我有一个Web应用程序,它在一个单独的线程中运行了一个SpringIntegration逻辑。问题是在某些时候我的SpringIntegration逻辑尝试使用请求范围的bean,然后我得到以下错误:Causedby:org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'scopedTarget.tenantContext':Scope'request'isnotactiveforthecurrentthread;considerdefiningascopedproxyfort
我有一个使用Spring-Security的Spring-Boot应用程序。我有一个请求范围的bean,我想将它Autowiring到安全过滤器链中的一个自定义过滤器中,但目前它不起作用。我了解在DispatcherServlet之外使用请求范围的bean需要一些配置,并且已阅读此http://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/beans.html#beans-factory-scopes-other但是还没有成功:ForServlet3.0+,thiscandoneprogrammatic
我有一个使用Spring-Security的Spring-Boot应用程序。我有一个请求范围的bean,我想将它Autowiring到安全过滤器链中的一个自定义过滤器中,但目前它不起作用。我了解在DispatcherServlet之外使用请求范围的bean需要一些配置,并且已阅读此http://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/beans.html#beans-factory-scopes-other但是还没有成功:ForServlet3.0+,thiscandoneprogrammatic
我已经google了,但没有找到满意的答案,如果你们能解释一下ContextLoaderListener和RequestContextListener之间的区别,那就太好了。 最佳答案 contextloaderlistener:-引导监听器以启动Spring的根WebApplicationContext。只需委托(delegate)给ContextLoader。requestcontextlistener:-该监听器主要用于第三方servlet,例如JSFFacesServlet。在Spring自己的web支持范围内,Dispat