User session overlay at different levels

Source: Internet
Author: User
a phenomenonSystem Admin Login

Login to Vendor Admin user under same browser

Because the top menu bar is present in session, when browsing the previous system administrator interface, click the menu option to get the menu bar content from the next login. Two AmendmentAdd an interceptor to redirect to home page when session exists Logininterceptor.java
Package jp.co.actoweb.core.interceptor;
Import Javax.servlet.http.HttpServletRequest;
Import Javax.servlet.http.HttpServletResponse;

Import javax.servlet.http.HttpSession;
Import Org.springframework.web.servlet.HandlerInterceptor;

Import Org.springframework.web.servlet.ModelAndView;

Import jp.co.actoweb.core.Constants;

	public class Logininterceptor implements Handlerinterceptor {private String homeurlmapping; @Override public boolean prehandle (HttpServletRequest request, httpservletresponse response, Object handler) throws Ex
		ception {HttpSession session = Request.getsession (); if (session!= null && session.getattribute (constants.session_key_auth_info)!= null) {Response.sendredirect (R
			Equest.getcontextpath () + gethomeurlmapping ());
		return false;
	return true; @Override public void Aftercompletion (HttpServletRequest request, httpservletresponse response, Object handler, EXCEP tion ex) throws Exception {} @Override public void Posthandle (HttpServletRequest request, HttpServletResponse response, Object handler, Modelandview Modelandview) throws Exception {
	Public String gethomeurlmapping () {return homeurlmapping;
	} public void Sethomeurlmapping (String homeurlmapping) {this.homeurlmapping = homeurlmapping;
 }

}
Configuration of the Interceptor in Mvc-config.xml
<bean id= "Logininterceptor" class= "Jp.co.actoweb.core.interceptor.LoginInterceptor" >
		<property name= "Homeurlmapping" value= "/admin/home/init.do"/>
	</bean>

<mvc:interceptor>
	    	<mvc:mapping path= "/**/admin/welcome.do"/>
	    	<ref bean= "Logininterceptor" />
	    </mvc:interceptor>
    </mvc:interceptors>




Related Article

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.