【发布时间】:2012-04-04 14:13:54
【问题描述】:
我都是,
我有一个使用基于角色的安全性的 Spring 应用程序。应用程序运行良好,只是我需要引入一些静态 HTML 页面,这些页面也将托管在同一战争中。因此,如果 www.myapp.com/abc/work.jsp 是我的安全页面,那么 www.myapp.com/home.htm 应该显示静态 html 页面。我已经合并了 HTML 文件,但问题是我在 www.myapp.com/home.htm 上得到 404,而 www.myapp.com/abc/work.jsp 工作正常。
web.xml -
<display-name>guru</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/app-security-config.xml</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/home.htm</welcome-file>
</welcome-file-list>
我的 app-security-config.xml
<http auto-config="false" disable-url-rewriting="false" access-decision-manager-ref="accessDecisionManager"
entry-point-ref="authenticationProcessingFilterEntryPoint">
<custom-filter position="FORM_LOGIN_FILTER" ref="authenticationProcessingFilter" />
<custom-filter position="LOGOUT_FILTER" ref="customLogoutFilter"/>
<access-denied-handler error-page="/login.jsp?login_error=true"/>
<intercept-url pattern="/login.htm" filters="none" />
<intercept-url pattern="/abc/def/**" access="ROLE_USER"/>
<intercept-url pattern="/**" access="ROLE_ANONYMOUS" />
<anonymous enabled='true'/>
<session-management session-authentication-strategy-ref="sas"/>
<custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" />
</http>
【问题讨论】:
-
此链接可能对您有所帮助stackoverflow.com/questions/1234298/…
-
“abc”是上下文根还是应用中的目录?
-
abc 是上下文根,这是生产代码,所以我已经屏蔽了它:)
-
我不认为
<welcome-file>正在做你认为它正在做的事情......stackoverflow.com/questions/2511301/… 在这方面可能会有所帮助。它仍然需要映射到 JSP,但我认为这并不能真正帮助您解决主要问题。 -
是的,欢迎文件无法正常工作,我尝试将其更改为 JSP,但也没有用。
标签: spring spring-mvc spring-security