Shiro Integrated SSH Development 3: Configure the Shiro post-certification page address jump problem (and details of the problem not configured to pay attention to)

Source: Internet
Author: User

in the video tutorial on the request for certification after successful jump page of the problem is a stroke, but I think it is necessary to write a separate article to narrate. I used SSH to integrate Shiro, after the development of the verification process, after each login Shiro will jump to an unknown JS, but the focus is my last visit address is:Edit
http://localhost:8080/shiro_05/user/login.action

After authentication should jump to the address of the last request, but Shiro jump to:

http://localhost:8080/shiro_05/user/js/eqmt.js
ben should have jumped to the last visited page, but jumped to the request path of this JS file, and this path is still weird. I guess this problem should be disturbing a lot of people, even if JS, CSS and other folders configured anonymous access, or the problem occurs: "After authentication address disorderly jump, not the last time you requested to come in the address." Someone even gave up the "jump to the previous request path" feature that Shiro comes with. There should be a lot of people to solve this problem, here, I will simply say it. After the inspection has finally found the problem: there is another non-absolute path in the page request address!

This article old cat original, reproduced please add this article connection:http://blog.csdn.net/nthack5730/article/details/51132560

more articles on old cats:http://blog.csdn.net/nthack5730



first of all, the address or request to configure the default authentication after successful Shiro:in the bean configuration of the Shirofilter
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">....</bean>

Add the Parameters:

<property name="successUrl" value="/user/list.action" />
it is possible to automatically forward to the address in value every time the authentication succeeds (I use/user/list.action, which is to request this address)
When this parameter is not configured, Shiro automatically requests the last address you visited. Assuming that you access the address: http://localhost:8080/shiro_01/user/
now assume that this address is required for authentication to be accessible, which is configured in the filter chain as /user/** = authc
then the certification page will be entered, and the above address will be saved to Shiro, when the authentication passed, the browser will automatically request access to the address just saved . http://localhost:8080/shiro_01/user/


However, when the page file is loaded incorrectly, the address is accessed after the authentication is completed: http://localhost:8080/shiro_01/user/***.***
my Pre-modified page after authentication the browser will visit the following address: http://localhost:8080/shiro_01/user/js/eqmt.js


This article old cat original, reproduced please add this article connection:http://blog.csdn.net/nthack5730/article/details/51132560

more articles on old cats:http://blog.csdn.net/nthack5730



Why this problem occurs, the reason is that the landing page may have some of the third-party loading style, JS and other files are not correctly entered. What is incorrect input, as long as the local server is requested, or the request is: http://localhost:8080/shiro_01/*******.***This form, that is, before the authentication and your previous visit to the page to access the server is Shiro interception of any address. will be Shiro automatically saved to the first request address of this variable, when you complete the certification will be Shiro will ask your browser automatically jump to this address . Note: The CDN mount does not count because it is not requesting this server. "

The following gives my page code, the request "comes with JS" This part is for the HTTP request instead of the absolute path loaded in:
<!--public Style file introduction --<Jsp:include page="template/css.jsp"></Jsp:include><!--comes with JS ---<Script src="Js/eqmt.js"></Script><!--self-built style sheets --<Link href="${pagecontext.request.contextpath}/css/eqmt.css" rel="stylesheet" type="Text/css"><Link href="${pagecontext.request.contextpath}/css/login.css" rel="stylesheet" type="Text/css">
except: <script src="js/eqmt.js"></script> This load is not successful through an absolute path, and then the browser automatically accesses the relative address, that is, the browser in the form of HTTP access, Shiro record the Eqmt.js file's access address (or the wrong address) the other is the internal absolute path access. "I've configured anonymous access to files in the filter chain that correspond to the absolute path."The problem can be solved by simply correcting or deleting the incorrectly loaded code or by mounting the file to CDN access:
<script src="${pageContext.request.contextPath}/js/eqmt.js"></script>
PS: Inside: ${pagecontext.request.contextpath} is the address of my project. JSP has this problem of egg pain, I believe many people know.
"The above summary is my personal feeling written, may be specific scientific names and adjectives used in the process of improper use, hope that we found after the point and help correct, grateful!" "

This article old cat original, reproduced please add this article connection:http://blog.csdn.net/nthack5730/article/details/51132560

more articles on old cats:http://blog.csdn.net/nthack5730




Shiro Integrated SSH Development 3: Configure the Shiro post-certification page address jump problem (and details of the issues not configured to be noted)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.