基于XML的Spring Security配置中的use-expressions属性等价于基于代码的配置

Flo*_*Flo 6 spring spring-security thymeleaf

如何use-expressions在基于代码的配置中启用Spring Security配置选项?需要此选项才能为Thymeleaf 启用基于表达式的访问控制用法.

在XML配置中,它看起来像这样:

...
<http auto-config="true" use-expressions="true" >
   ...   
</http>
...
Run Code Online (Sandbox Code Playgroud)

Shi*_*Kai 6

根据博客文章,use-expressions在使用Java配置时设置为true.

Comparison to XML Namespace
...
One difference is that Java Configuration uses authorizeUrls 
to specify use-expressions="true"
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助.