Spring: What parser to use to parse security expressions

喜夏-厌秋 提交于 2019-12-24 21:42:29

问题


I would like to parse standard security expressions like hasRole etc. to get their value in a variable (in a JSP). How can I do that? SpelExpressionParser is the standard EL parser, but I don't think it will parse the security expression.


回答1:


The simpliest approach is to use a <sec:authorize> tag and modify a desired variable inside its body.

If you actually want to evaluate expressions manually, look at the source of AuthorizeTag - it gets the first bean of type WebSecurtyExpressionHandler from the web application context and uses it to obtain ExpressionParser and EvaluationContext.




回答2:


I've posted an answer in this topic here - How to parse spring security expressions programmatically. I think this answers your question also.



来源:https://stackoverflow.com/questions/3048623/spring-what-parser-to-use-to-parse-security-expressions

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