zoukankan      html  css  js  c++  java
  • 从struts2源码学到的技巧

    1把字符串转为set集合

    includeMethods=“abc,ext,spring”;

    com.opensymphony.xwork2.util.TextParseUtil.commaDelimitedStringToSet(includeMethods);

    2正则表达式过滤方法

    method方法的名称

    excludeMethods不包括的正则表达(Set<String>集合)

    includeMethods包括的正则表达(Set<String>集合)

    com.opensymphony.xwork2.interceptor.MethodFilterInterceptorUtil.applyMethod(excludeMethods, includeMethods, method);

    3equals写法

    @Override
    public boolean equals(Object o) {
    if (!(o instanceof Key)) {
    return false;
    }
    if (o == this) {
    return true;
    }
    Key other = (Key) o;
    return name.equals(other.name) && type.equals(other.type);
    }

    4将字符的true或false变为布尔型

    throwException为true或false的字串

     this.throwExceptionOnELFailure = "true".equals(throwException);

    5 判定此 Class 对象(clazz)所表示的类或接口与指定的 Class 参数所表示的类或接口是否相同,或是否是其超类或超接口。

    clazz.isAssignableFrom(component.getClass()) 

    6先获取实现TemplateEngine接口的类的名字。然后构造它们的对象,放到map里面去。

    Set<String> prefixes = container.getInstanceNames(TemplateEngine.class);
    for (String prefix : prefixes) {
    map.put(prefix, new LazyEngineFactory(prefix));
    }

    7解析字符串

    configPaths="struts-default.xml,struts-plugin.xml,struts.xml";

    String[] files = configPaths.split("\\s*[,]\\s*");

    Java交流群 241351407         可能满了

  • 相关阅读:
    Select2插件的隐藏、设置宽度
    远程登陆Linux服务器
    ECMAScript typeof用法
    Select2异步搜索数据
    ECMAScript 引用类型
    LeetCode 任务调度器-Python3<八>
    sort、sorted高级排序-Python3.7 And 算法<七>
    LeetCode算法笔记目录
    数据结构-Python3.7<三>
    【夯实PHP基础】php开发时遇到白页的调试方法
  • 原文地址:https://www.cnblogs.com/angelshelter/p/2764135.html
Copyright © 2011-2022 走看看