在用spring security作权限控制的过程中,遇到以下需求:
如果用户已经登录了,那么输入主页url时不要到登录页(index.html),而是直接跳到登录后的主页(main.html)。
由于"/"和"index.html"本来不需要权限,所以在applicationContext-security.xml里是如下配置的
<s:intercept-url pattern="/" filters="none" />
<s:intercept-url pattern="/index.html" filters="none" />
本想去掉这两行在自定义的ProcessingFilter里判断如果登录就直接chain.filter(...),结果发现不行。因为如果不用filters="none",那么spring security缺省会匹配到/**,而/**是有权限要求的。
没办法,只好自己写一个Filter配到web.xml中实现此功能。当然,这样看上去很不优雅,不过暂时没有更好的解决方法。这里要注意,按照servlet 2.4 spec的说法,对于mapping中的url
写道
• A string containing only the ’/’ character indicates the "default" servlet of
the application. In this case the servlet path is the request URI minus the context
path and the path info is null.
但实际上如果自己写的那个Filter在mapping中配成
<filter-mapping>
<filter-name>directlyNavigateToMainPageWhenAuthenticationSuccessFilter</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
是怎么也捕捉不到"/"和”/index.html“的,解决方法是直接在这里配成welcome-page中的地址
<filter-mapping>
<filter-name>directlyNavigateToMainPageWhenAuthenticationSuccessFilter</filter-name>
<url-pattern>/index.html</url-pattern>
</filter-mapping>
这样就能捕获了。
不知道是我对spec理解错误了吗?总觉得 "/"应该可以捕获缺省页的啊。
分享到:
相关推荐
赠送jar包:jakarta.xml.bind-api-2.3.3.jar; 赠送原API文档:jakarta.xml.bind-api-2.3.3-javadoc.jar; 赠送源代码:jakarta.xml.bind-api-2.3.3-sources.jar; 赠送Maven依赖信息文件:jakarta.xml.bind-api-...
jboss-web.xml jndi.properties oracle-ds.xml三个文件,EJB+JPA 所需要的一些配置文件
部署描述文件web.xml详解(web-app_2_3.dtd),全面介绍: 1. icon元素 2. display-name元素 3. description元素 4. distributable元素 5. context-param元素 6. filter元素 7. filter-mapping元素 8. ...
演示web.xml文件中error-page标签的使用.zip,欢迎下载!
了解web.xml的配置信息和加载顺序,有助于理解框架的流程,
Error creating bean with name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0' defined in ServletContext resource [/WEB-INF/springMVC-servlet.xml]: Initialization of bean failed;...
安卓sdk找不到的api,因此需要引入额外的jar包1
请在web.xml文件中使用– page >元素为整个web应用程序设置错误处理页面。已知:处理状态码为404的页面为404.jsp,处理状态码为500的页面为500.jsp。
servlet的写登陆管理系统用到的web.xml
web.xml配置详解web.xml配置详解web.xml配置详解web.xml配置详解web.xml配置详解web.xml配置详解web.xml配置详解
Addison.Wesley.XForms.XML.Powered.Web.Forms.eBook-LiB.chm Addison.Wesley.XForms.XML.Powered.Web.Forms.eBook-LiB.chm
spring-mvc.xml spring-mybatis.xml web.xml log4j.properties,项目中需要用到的配置文件。直接可用。
web.xml 中的listener、 filter、servlet 加载顺序及其详解
在web.xml中引入其他xml配置文件的步骤,含引入错误解决。
在web服务器中如tomcat、jboss等中部署axis2时,所需要的文件:jaf-1_1-fr.zip,javamail-1_4.zip ,xml-security-bin-1_2_1.zip
全面详细讲述web.xml个元素的用途 还有实例哦
Jboss启动报Failed to parse WEB-INFweb.xml; - nested throwable错误
web.xml配置文件详解让开发人员更加清楚web.xml是怎么配置。以及各个配置的作用。
Filter过滤器的代码及其web.xml配置代码 很好的解决网页乱码问题,很方便,只要按照名字添加就可以了
在java web.xml的使用你也可以去百度找 这里有大部分的< mime - mapping extension = " .au " mime - type = " audio/basic " /> 很多格式