Java Spring Security-在sessionManagement中的expiredUrl上显示HTML页面
我想在我的java spring安全性中配置Java Spring Security-在sessionManagement中的expiredUrl上显示HTML页面,java,angularjs,spring,spring-mvc,spring-security,Java,Angularjs,Spring,Spring Mvc,Spring Security,我想在我的java spring安全性中配置expiredUrl(“”)功能。 我想在并发会话过期时显示HTML页面 我尝试了以下方法:- JAVA @Override public void configure(HttpSecurity http) throws Exception { http .sessionManagement() .sessionFixation() .changeSessionId()
expiredUrl(“”)
功能。我想在并发会话过期时显示HTML页面
我尝试了以下方法:- JAVA
@Override
public void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionFixation()
.changeSessionId()
.maximumSessions(1)
.expiredUrl("/session_expired.html")
}
@Override
public void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionFixation()
.changeSessionId()
.maximumSessions(1)
.expiredUrl("/access/session_expired")
}
我的上下文路径设置为localhost:8080/context\u path
但是我不知道如何在expiredUrl call上显示
会话\u expired.html
页面我在Js端使用angularJs
请帮助我在expiredUrl调用中显示Html页面 及 如果我在Js的帮助下尝试,那么我的代码是:- JAVA
@Override
public void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionFixation()
.changeSessionId()
.maximumSessions(1)
.expiredUrl("/session_expired.html")
}
@Override
public void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionFixation()
.changeSessionId()
.maximumSessions(1)
.expiredUrl("/access/session_expired")
}
ANGULARJS
$stateProvider.state('session_expired', {
'url': '/session_expired',
'templateUrl': '/session_expired.html',
'controller': 'SessionExpiredController'
})
.factory('SessionService', function ($resource, restRoot, contextPath) {
return $resource({
'session_expired': {
'url': contextPath + '/access/session_expired'
},
})
.controller('SessionExpiredController', function (SessionService, $state) {
SessionService.session_expired(function () {
$state.go("session_expired");
});
});
这里,当会话过期时,它将进入链接localhost:8080/context\u path/session\u expired\35;/landing…
但我想继续链接
localhost:8080/context_path/#/session_过期
或
我想在expiredUrl
因此,请指导我如何执行此操作。此配置适用于我:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/", "/list")
.access("hasRole('USER') or hasRole('ADMIN') or hasRole('DBA')")
.antMatchers("/newuser/**", "/delete-user-*").access("hasRole('ADMIN')").antMatchers("/edit-user-*")
.access("hasRole('ADMIN') or hasRole('DBA')").and().formLogin().loginPage("/login")
.loginProcessingUrl("/login").usernameParameter("ssoId").passwordParameter("password").and()
.rememberMe().rememberMeParameter("remember-me").tokenRepository(tokenRepository)
.tokenValiditySeconds(86400).and().csrf().and().exceptionHandling().accessDeniedPage("/Access_Denied");
}
是,但我想在会话过期时显示HTML页面,因此,当我的会话过期时,它将进入路径
localhost:8080/context\u path/session\u expired#/…
,而不是这个路径,我想重定向到localhost:8080/context\u path/#/session\u expired
,或者我想返回expiredUrl
中的html页面,那是什么/Access\u Denied
?这是一个被拒绝访问的页面,如果不允许用户访问特定的url,将显示该页面。你能给我分享一下该代码吗?你是如何显示被拒绝访问的页面的?该代码是共享的。。例如,如果角色为“user”的用户尝试在浏览器栏中键入删除URL并输入。他应该会看到AccessDenied页面。。在我的示例中,只有具有“Admin”角色的用户才能访问删除URL。您是否尝试过类似StackOverflow的操作?然后直接转到你的页面?或者创建过滤器并在那里检查(和重定向)?也许在这里