`
zenius
  • 浏览: 55844 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

Spring Special Code

阅读更多
Set flow and menu item mapping
 
    public void setLocationMaps(MenuComponent[] menuComponents) {

        for (MenuComponent menuComponent: menuComponents) {
           if (null == this.locationMapping.get(menuComponent.getLocation()) 
                   || null != menuComponent.getParent()) {
               this.locationMapping.put(menuComponent.getLocation(), menuComponent);
           }
           if (menuComponent.getMenuComponents().length > 0) {
               this.setLocationMaps(menuComponent.getMenuComponents());
           }
        }
    }




Once Request filter
public class MenuFilter extends OncePerRequestFilter {

    /**
     * This method looks for a "locale" request parameter. If it finds one, it sets it as the preferred locale
     * and also configures it to work with JSTL.
     * 
     * @param request the current request
     * @param response the current response
     * @param chain the chain
     * @throws IOException when something goes wrong
     * @throws ServletException when a communication failure happens
     */
    @SuppressWarnings("unchecked")
    public void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
                                 FilterChain chain)
            throws IOException, ServletException {


        chain.doFilter(request, response);

        // Reset thread-bound LocaleContext.
        LocaleContextHolder.setLocaleContext(null);
    }
}

Flow Execution listener and external context
public class MenuFlowLister extends FlowExecutionListenerAdapter {

    public void requestProcessed(RequestContext context) {
        String id = context.getActiveFlow().getId();

        MenuRepository menus = (MenuRepository) context.getExternalContext().getApplicationMap()
                .get(MenuRepository.MENU_REPOSITORY_KEY);
    }
}


Get session attributes
        Object mutex = RequestContextHolder.currentRequestAttributes().getSessionMutex();
        RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();
        String test;
        synchronized (mutex) {
            test = (String)attributes.getAttribute("zenius", RequestAttributes.SCOPE_SESSION);
        }
        return test;
分享到:
评论
1 楼 iql 2009-03-12  
你好,请教一下为什么要这样来取session中的值?而不用HttpSession?

相关推荐

    spring-framework-reference-4.1.2

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

    Spring.Boot.in.Action.2015.12.pdf

    Special sales department Manning publications co 20 Baldwin Road PO BoX 761 Shelter island. ny11964 Emailorders@manning.com @2016 by manning Publications Co. All rights reserved No part of this ...

    spring-framework-reference4.1.4

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

    cloudtest-1.0.4-b201302231138PM Release

    Every organization or individual is fully granted for viewing its source code or modify the source codes to match his/her own special needs; commercial applications have the greatest license under ...

    MCA-SIG面试预备

    MCA-SIG面试预备这是Interview Preparation Special Interest Group (SIG)与Mizzou Computing Association (MCA)合作使用的资料库。 在2021年Spring学期中,每周的内容都将上载到该存储库中。内容将包括:指导,练习...

    Beginning Perl

    Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer- sbm.com,...

    Java 9 Programming By Example

    See the workings of the Spring framework and use Java annotations for the configuration Master the scripting API built into the Java language and use the built-in JavaScript interpreter Understand ...

    Java.9.Programming.By.Example.epub

    See the workings of the Spring framework and use Java annotations for the configuration Master the scripting API built into the Java language and use the built-in JavaScript interpreter Understand ...

    基于ssm+mysql的在线订花系统源码数据库论文.docx

    编程技术 to develop an online flower ordering system ...JSP (JavaServer Pages), a core technology in this project, is a server-side scripting language that allows developers to embed Java code within ...

    thymeleaf-extras-eclipse-plugin-2.1-master.zip

    thymeleaf-core, thymeleaf-spring3, thymeleaf-extras-springsecurity3, and thymeleaf-extras-tiles2 projects already have such files. Other dialects, however, are up to the discretion of their developer...

    CMAC:AES-CMAC (NIST 800-38B)

    AES-CMAC,全称是Advanced Encryption Standard - Cipher-based Message Authentication Code,是基于AES(高级加密标准)的密码消息认证码算法,按照NIST(美国国家标准和技术研究所)的规范800-38B进行定义。...

    雷达技术知识

    APPENDIX: ARCGIS VBA SCRIPT CODE 58 REFERENCES 106 IX LIST OF FIGURES Figure Page 1. Return Factor vs. LiDAR Scan Angle 2 2. Angle of Incidence 3 3. Wave Action Relationship to LiDAR Echo 3 4. Site ...

Global site tag (gtag.js) - Google Analytics