These two days found a problem, title, tried a lot of methods, can not solve, really depressed. Finally see the source code to know, my configuration is as follows. The original intention is from/api/user/login login success, jump to/index, but how can not jump to/index. The original AUTHC interceptor (ie, formauthenticationfilter), verification success will only jump to the beginning of the page you enter, because I am from the/api/user/login page into the login, so will only jump to/api/user/login. To jump to the/index page, only the first entry from the/index page, the background will be redirected to the/api/user/login page, the verification is successful, only return to the/index page.
The configuration is as follows:
<!--Shiro Web filter, ID to be consistent---<bean id= "Shirofilter" class= "Org.apache.shiro.spring.web.ShiroFilte" Rfactorybean "> <property name=" SecurityManager "ref=" SecurityManager "/> <property name=" Login Url "value="/api/user/login "/> <property name=" Successurl "value="/index "/> <property name="
Unauthorizedurl "value="/unauthorized "/> <property name=" Filters "> <map>
<entry key= "authc" value-ref= "Formauthenticationfilter"/> </map> </property>
<property name= "Filterchaindefinitions" > <value>/static/** = anon
/api/user/login = Authc/api/user/logout = logout/api/user/register* = Anon /unauthorized = Anon/** = user </value> </property> </bea N>
Formauthenticationfilter Part Source:
Protected Boolean onloginsuccess (Authenticationtoken token, Subject Subject,
servletrequest request, Servletresponse response) throws Exception {
issuesuccessredirect (request, response);
We handled the success redirect directly, prevent the chain from continuing:
return false;
}
From the source code we can see that after the successful login, will be executed
protected void Issuesuccessredirect (ServletRequest request, servletresponse response) throws Exception {
Webutils.redirecttosavedrequest (Request, Response, Getsuccessurl ());
}
This method is
public static void Redirecttosavedrequest (ServletRequest request, servletresponse response, String Fallbackurl)
Throws IOException {String successurl = null;
Boolean contextrelative = true;
Savedrequest savedrequest = webutils.getandclearsavedrequest (request);
if (savedrequest! = null && Savedrequest.getmethod (). Equalsignorecase (Accesscontrolfilter.get_method)) {
Successurl = Savedrequest.getrequesturl ();
Contextrelative = false;
} if (Successurl = = null) {Successurl = Fallbackurl; } if (Successurl = = null) {throw new IllegalStateException ("Success URL not available via saved requ EST or via the "+" Successurlfallback method parameter.
One of these must is non-null for "+" issuesuccessredirect () to work. ");
Webutils.issueredirect (Request, response, Successurl, NULL, contextrelative); }
The
key is Successurl = Savedrequest.getrequesturl (), which will reassign the Successurl and the configured/index to fail.