Using Interceptor to validate user access privilege

后端 未结 2 812
温柔的废话
温柔的废话 2020-12-07 05:12

I am trying to use an Interceptor to restrict users from performing certain actions.

ContainsKeyInterceptor:



        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 05:46

    Based on this I don't think the interceptor itself can / needs to be session aware.

    You can access this property as such:

    final ActionContext context = actionInvocation.getInvocationContext();  
    this.session = context.getSession();  
    

    There may be a way to get this set automatically, I'm not too familiar with struts2, but it could be that the sessionaware only works for a specific subset of objects and this interceptor isn't one of them for some reason. (not being scanned, being excluded from scan, of the wrong type)

提交回复
热议问题