spring 没有重定向到默认目标 url? [英] spring is not redirecting to default target url?

查看:22
本文介绍了spring 没有重定向到默认目标 url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Spring Security 进行身份验证.身份验证工作正常.但在身份验证后,它不会重定向到使用 spring 安全配置文件中的默认目标 url 提到的 html.我收到简单的消息成功.但不是已配置的 html 页面.我在下面添加了用于重定向的行.

I am using spring security for authentication. authentication is working fine. but after authentication it is not redirecting to the html that have mentioned using default target url in spring security configuration file. i am getting simple message Success. but not the html page that have configured. i have added below line for redirection.

<form-login login-page="/login.jsp" default-target-url="/welcome.html"/>

我是否缺少要配置的任何东西.

am i missing anything to configure.

谢谢!

推荐答案

如果用户在请求受保护的资源后进入登录页面,则在登录成功后将被发送至最初请求的页面.默认-target-url 仅在用户登录时未先请求受保护资源(即他们直接导航到登录页面)时使用.如果你总是想转到 default-target-url 你可以指定 always-use-default-target="true" 如下例所示

If a user is sent to the login page after requesting a protected resource, they will be sent to the originally requested page after successful login. The default-target-url will only be used if the user logged in without requesting a protected resource first (i.e. they navigated directly to the login page). If you always want to go to the default-target-url you can specify always-use-default-target="true" as shown in the example below

<form-login login-page="/login.jsp" 
            default-target-url="/welcome.html" 
            always-use-default-target="true"/>

这篇关于spring 没有重定向到默认目标 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆