Spring Boot在登录URL中附加先前输入的URL

时间:2018-07-31 13:15:27

标签: java spring spring-boot spring-security

我正在使用Spring Security项目进行Spring Boot,并且需要以下问题的帮助。

现在,它正在这样工作- 当任何用户尝试访问Alias /ezproxy-config "/opt/rh/httpd24/root/var/www/sites/staff2.library.ohio.edu/apps/app-ezproxy-config/current/public/" <Directory /opt/rh/httpd24/root/var/www/sites/staff2.library.ohio.edu/apps/app-ezproxy-config/current/public/> AllowOverride All Include conf.d/vhosts.d/includes/h5bp.conf AuthType Basic AuthName "Library Web Services Staff - Enter OHIO ID and Password" AuthBasicProvider ldap AuthLDAPBindDN "LIB-LDAPsvc@ohio.edu" AuthLDAPBindPassword Drtbovr_Svvy AuthLDAPURL ldap://ad.ohio.edu:389/OU=People,DC=Ohio,DC=Edu?cn,displayname,department,mail <RequireAny> Require ldap-group CN=Lib_Dept_IT,OU=Departments,OU=Groups,OU=LIBRARY,OU=Ohio,DC=ohio,DC=edu Require ip 132.235.61.22 </RequireAny> </Directory> 链接时,他/她都将重定向到http://localhost:8080/coinMarketCap(这是登录页面)。

现在,我要实现的是- 当任何用户尝试访问http://localhost:8080/链接时,他/她将被重定向到http://localhost:8080/coinMarketCap(这是登录页面)。

请注意,URL中附加了http://localhost:8080/?target=coinMarketCap

项目的GitHub链接:Link 配置文件:Link

我已经搜索了,但是找不到解决方案。 请帮我解决这个问题。预先感谢。

1 个答案:

答案 0 :(得分:0)

如果要将参数添加到登录页面,最简单的方法可能是添加具有以下路径参数的处理程序:

@RequestMapping(path="/{name}/{age}")
public String getMessage(@PathVariable("name") String name, 
        @PathVariable("age") String age) {
    <here redirect to "/" with parameters>
}

在Thymeleaf中,它的工作方式如下:

return "redirect:/?name=" + name + "&age=" + age;

您可以找到许多指南,介绍如何使用Spring进行重定向。但是您需要打开对所有需要这种处理的页面的访问权限。