struts2的路径具有按包容错机制。
比如访问test.action 正确路径为(忽略namespace):http://ip:端口/项目名/test.action ,
但是struts2提供容错机制 则访问:http://http://ip:端口/项目名/包1/包2/包n/test.action 都可以正确访问到。
当springSecurity2.x和struts2配合使用时,在web.xml中springSecurity的filter要配置到struts的前面,这样才能保证springSecurity的过滤器不会被struts2拦截掉。
当springSecurity资源配置为/aa.action时,正常情况下访问 http://ip:端口/项目名/test.action springSecurity会拿到 /test.action去spring缓存中对比,发现有此资源配置,则判断登陆用户是否拥有该权限,正常执行……
若访问http://http://ip:端口/项目名/包1/包2/包n/test.action springSecurity会拿到 /包1/包2/包n/test.action去spring缓存中对比,发现无此资源配置,则通过。到struts2过滤器时,将/包1/包2/包n/test.action容错,找到正确的http://ip:端口/项目名/test.action 访问成功。
这样,springSecurity中对于action的权限控制就会被破坏。
求解答:
1、struts2是否由相关配置关掉路径容错?
2、springSecurity在路径对比时,调用AntPathMatcher中doMatch,是否有必要重写此方法?