Tag: 检票口

编程使用Spring Security

我在Wicket Auth Project中使用Wicket作为我的表示层,因此我将它与Spring Security集成在一起。 这是Wicket为我所authentication的方法: @Override public boolean authenticate(String username, String password) { try { Authentication request = new UsernamePasswordAuthenticationToken( username, password); Authentication result = authenticationManager.authenticate(request); SecurityContextHolder.getContext().setAuthentication(result); } catch (AuthenticationException e) { return false; } return true; } 我的Spring Security XMLconfiguration的内容是: <http path-type="regex"> <form-login login-page="/signin"/> <logout logout-url="/logout" /> </http> <global-method-security secured-annotations="enabled" /> <authentication-manager alias="authenticationManager"/> <authentication-provider […]

范围“会话”对于当前线程不活跃; IllegalStateException:找不到线程绑定的请求

我有一个控制器,我想每个会话都是唯一的。 根据春季文档,有两个细节执行: 1.初始网页configuration 为了在请求,会话和全局会话级别(Web范围的bean)上支持bean的范围界定,在定义bean之前需要一些次要的初始configuration。 我已经将以下内容添加到我的web.xml ,如文档中所示: <listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener> 2.作为依赖关系的作用域bean 如果您想要将HTTP请求范围的bean注入(例如)另一个bean,则必须注入一个AOP代理来代替范围的bean。 我用@Scope注释了bean,提供了proxyMode ,如下所示: @Controller @Scope(value="session", proxyMode=ScopedProxyMode.TARGET_CLASS) public class ReportBuilder implements Serializable { … … } 问题 尽pipe有了上面的configuration,但我得到了以下例外: org.springframework.beans.factory.BeanCreationException:创build名为'scopedTarget.reportBuilder'的bean时出错:作用域'session'对当前线程不活跃; 考虑为这个bean定义一个范围代理,如果你打算从一个单例中引用它; 嵌套的exception是java.lang.IllegalStateException:没有发现线程绑定的请求:是否引用实际Web请求之外的请求属性,或者在原始接收线程之外处理请求? 如果您实际上在Web请求中运行并仍然收到此消息,那么您的代码可能在DispatcherServlet / DispatcherPortlet之外运行:在这种情况下,请使用RequestContextListener或RequestContextFilter来公开当前请求。 更新1 以下是我的组件扫描。 我在web.xml有以下内容: <context-param> <param-name>contextClass</param-name> <param-value> org.springframework.web.context.support.AnnotationConfigWebApplicationContext </param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>org.example.AppConfig</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> 以下在AppConfig.java : @Configuration @EnableAsync […]