这是我的实体类:
class ModelEntity {
List<String> list;
...
}
现在我想发布过滤器返回的对象并仅返回列表包含“某物”的对象。这可能吗?如果是,该怎么做? 我相信它必须是这样的(ofc.改变“包含”):
@PostFilter("(filterObject.list contains 'something')")
List<ModelEntity> findAll()
最佳答案
我不认为 Spring 表达式引擎提供“包含”作为开箱即用的解决方案。
检查this Spring 安全表达式的链接。
但是您可以为此定义自己的自定义表达式处理程序。
在 Spring 中定义自定义表达式处理程序的方法有很多种。- 通过实现PermissionEvaluator。
- 通过实现MethodSecurityExpressionOperations。
有关示例和更多说明,请关注 this博客。
关于java - @PostFilter 包含?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48419535/