`
zenius
  • 浏览: 55080 次
  • 性别: 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 ...

    CloudTest Getting Started Guide.pdf

    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,...

    Beginning JavaFX

    Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-...

    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 ...

    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...

    Pro HTML5 Programming: Powerful APIs for Richer Internet Application Development

    Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-...

    Wrox.Professional.jQuery 2012

    jQuery is prominently featured at the front end of Java/Spring, PHP, .NET, Ruby on Rails, and Python/Django stacks all over the Web. If you have experience with HTML, CSS, and JavaScript, this book ...

    雷达技术知识

    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