zoukankan      html  css  js  c++  java
  • play @Before 的使用

    用play 框架也又一段时间了,也算是有了些经验,今天就总结下@Before 的使用。

    这个注解能主要在控制器中使用,用于在Action 前进行拦截

    unless 表示不用拦截 的Action

    @Before(unless = {"getIndexData", "getCategory", "getDetail", "getRecommends"})
        private static void authFilter(String sessionKey, int appCode) {
            RequestResult requestResult = null;
            if (GeneralUtil.isMultiHasNullOrZero(sessionKey, appCode)) {
                renderJSON(new RequestResult(ResponseCode.USER_NOT_SESSION));
    
            }
        }
    

      

    only 表示只拦截某个Action

    @Before(only ="getOnlyData")
        private static void authFilter(String sessionKey, int appCode) {
            RequestResult requestResult = null;
            if (GeneralUtil.isMultiHasNullOrZero(sessionKey, appCode)) {
                renderJSON(new RequestResult(ResponseCode.USER_NOT_SESSION));
    
            }
        }
    

      

  • 相关阅读:
    Fibonacci Numbers
    Fibonacci(...刷的前几道题没有记博客的习惯,吃了大亏)
    Fibonacci Check-up
    Pendant
    奥运
    Tr A
    A Simple Game
    Be the Winner
    John
    Being a Good Boy in Spring Festival(尼姆博弈)
  • 原文地址:https://www.cnblogs.com/zeopean/p/7906520.html
Copyright © 2011-2022 走看看