Exemplo n.º 1
0
  /**
   * 构建actionkey,参考ActionMapping中的实现。
   *
   * @param controllerClass
   * @param method
   * @param controllerKey
   * @return
   */
  private String createActionKey(
      Class<? extends Controller> controllerClass, Method method, String controllerKey) {
    String methodName = method.getName();
    String actionKey = "";

    ActionKey ak = method.getAnnotation(ActionKey.class);
    if (ak != null) {
      actionKey = ak.value().trim();
      if ("".equals(actionKey))
        throw new IllegalArgumentException(
            controllerClass.getName()
                + "."
                + methodName
                + "(): The argument of ActionKey can not be blank.");
      if (!actionKey.startsWith(SLASH)) actionKey = SLASH + actionKey;
    } else if (methodName.equals("index")) {
      actionKey = controllerKey;
    } else {
      actionKey =
          controllerKey.equals(SLASH) ? SLASH + methodName : controllerKey + SLASH + methodName;
    }
    return actionKey;
  }