这里是我的春天安全文件:春季安全拦截的URL不工作的单页应用
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/login" access="isAnonymous()" />
<intercept-url pattern="/stat" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/articles" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/**" access="hasRole('ROLE_ADMIN')" />
<form-login login-page="/index.html#/login"
default-target-url="/index.html#/articles"
authentication-failure-url="/index.html#/login?error"
username-parameter="username" password-parameter="password" />
<logout logout-success-url="/index.html#/login?logout" />
</http>
我在这里提拦截的URL“/ **”只在最后。
下面是我的web.xml:
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:dispatcher-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- for spring security -->
<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>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-security.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
但还是我得到重定向问题,/登录和其他URL模式没有得到映射到处理程序!
这里是app.js:
searchApp.config([ '$routeProvider', function($routeProvider) {
$routeProvider.when('/articles', {
templateUrl : 'partials/articles-list-accordian.html',
controller : 'ArticlesController'
}).when('/login', {
templateUrl : 'partials/login.html',
controller : 'LoginControllers'
}).when('/stat', {
templateUrl : 'partials/job-stat.html',
controller : 'JobStatController'
}).otherwise({
/*redirectTo : '/welcome'*/
redirectTo : '/articles'
});
} ]);
请指引我在这里,我是新手,是春天的安全性,从而可能会犯一些愚蠢的错误..
你想拦截服务器端的客户端路由吗? –
对不起延迟@RaghuVenmarathoor只有正常的服务器端路由。 –