如何在Struts 2上使用Spring Security 3?
我已经阅读了很多关于在Struts 2上使用Spring Security 3的教程。但是我无法使它工作:/。
关于在Struts 2上实现这个框架,我找不到“Dummy step by step guide”。
这是我有的:
web.xml中:
struts2 org.apache.struts2.dispatcher.FilterDispatcher struts2 /* org.springframework.web.context.ContextLoaderListener cv 30 example/HelloWorld.jsp
security.xml文件
还有我的HelloWorld.jsp
Welcome!
This session will be visible to an admin only.
You are an Administrator.
This session will be visible to an Customer only.
You are an Customer.
${HelloMessage}
<a href="https://stackoverflow.com/questions/12607719/how-use-spring-security-3-on-struts-2/">Logout
我想测试权限如何使用标记“isAnonymous”显示该文本块,但我无法使其工作
🙁
您需要将Spring Security的filter链添加到web.xml。
springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /*
这是在你的Strutsfilter之后。 这将允许Spring Security在Struts提交请求之前检查/阻止请求。
假设允许用户访问内容,Spring Security将设置一个SecurityContext对象,该对象将允许JSP标记工作。