instanceof in SpEL

假装没事ソ 提交于 2021-01-27 06:50:47

问题


i have a class with the method: Code:

List<Entity> getData() {...}

and some classes which extends Entity: Project, Phase, Invoice, Payment.

and i would like to do something like this:

@PostFilter("filterObject instanseof Project ? filterObject.manager == principal : filterObject instanceof Phase ? filterObject.project.manager == principal : 
filterObject instanceof Invoice ? filterObject.phase.project == principal : filterObject instanceof Payment ? filterObject.invoice.phase.project.manager == principal : true")

is it a legal? or how to use "instanceof" correctly?


回答1:


The correct syntax for SpEL would be like filterObject instanceof T(Project). (Please see SpEL section 6.5.6.1 - Relational operators)



来源:https://stackoverflow.com/questions/7628437/instanceof-in-spel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!