SpEL无法解析变量

时间:2017-09-17 19:16:21

标签: spring spring-el

我尝试使用SpEL将userId方法中的mvcMatchers参数传递给access()方法。
这基于教程Spring Security 4.1 and Beyond

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.csrf()
            .disable()
        .authorizeRequests()
            .mvcMatchers(HttpMethod.GET, "/", "/home").permitAll()
            .mvcMatchers("/users/{userId}").access("@authz.check(#userId,principal)")
            .mvcMatchers(HttpMethod.POST, SIGN_UP_URL).permitAll()
            .mvcMatchers("/admin").denyAll()
            .anyRequest().authenticated()
            .and()
        .logout().permitAll()
            .and()
        .addFilter(new JWTAuthenticationFilter(authenticationManager()))
        .addFilter(new JWTAuthorizationFilter(authenticationManager()));
}

据我所知,{userId}中的mvcMatchers()应该成为一个变量,可以传递给access

这种方式会引发异常:Cannot resolve variable userId

我对Spring(Boot)相当新,对SpEL来说是全新的。

我希望有人可以帮助我。

0 个答案:

没有答案
相关问题