public static String generateSetCookie(Cookie cookie) {
    if (cookie == null) {
      throw new IllegalArgumentException("the cookie is null");
    } else {
      StringBuilder sb = new StringBuilder();

      sb.append(cookie.getName()).append('=').append(cookie.getValue());

      if (VerifyUtils.isNotEmpty(cookie.getComment())) {
        sb.append(";Comment=").append(cookie.getComment());
      }

      if (VerifyUtils.isNotEmpty(cookie.getDomain())) {
        sb.append(";Domain=").append(cookie.getDomain());
      }
      if (cookie.getMaxAge() >= 0) {
        sb.append(";Max-Age=").append(cookie.getMaxAge());
      }

      String path = VerifyUtils.isEmpty(cookie.getPath()) ? "/" : cookie.getPath();
      sb.append(";Path=").append(path);

      if (cookie.getSecure()) {
        sb.append(";Secure");
      }

      sb.append(";Version=").append(cookie.getVersion());

      return sb.toString();
    }
  }
 @Override
 public Cookie[] getCookies() {
   if (cookies == null) {
     List<Cookie> list = new ArrayList<Cookie>();
     String cookieStr = getHeader("Cookie");
     if (VerifyUtils.isEmpty(cookieStr)) {
       cookies = EMPTY_COOKIE_ARR;
     } else {
       String[] c = StringUtils.split(cookieStr, ';');
       for (String t : c) {
         int j = 0;
         for (int i = 0; i < t.length(); i++) {
           if (t.charAt(i) == '=') {
             j = i;
             break;
           }
         }
         if (j > 1) {
           String name = t.substring(0, j).trim();
           String value = t.substring(j + 1).trim();
           Cookie cookie = new Cookie(name, value);
           list.add(cookie);
         } else continue;
       }
       cookies = list.toArray(EMPTY_COOKIE_ARR);
     }
   }
   return cookies;
 }
  @Override
  public boolean isRequestedSessionIdFromURL() {
    if (requestedSessionId != null) return requestedSessionIdFromURL;

    String sessionId = getSessionId(requestURI, config.getSessionIdName());
    if (VerifyUtils.isNotEmpty(sessionId)) {
      requestedSessionId = sessionId;
      requestedSessionIdFromURL = true;
      return true;
    }
    return false;
  }
  private void loadParam(String str) throws UnsupportedEncodingException {
    if (VerifyUtils.isNotEmpty(str)) {
      String[] p = StringUtils.split(str, '&');
      for (String kv : p) {
        int i = kv.indexOf('=');
        if (i > 0) {
          String name = kv.substring(0, i);
          String value = kv.substring(i + 1);

          List<String> list = parameterMap.get(name);
          if (list == null) {
            list = new ArrayList<String>();
            parameterMap.put(name, list);
          }
          list.add(URLDecoder.decode(value, characterEncoding));
        }
      }
    }
  }
  /**
   * controller方法参数注入
   *
   * @param request
   * @param response
   * @param mvcMetaInfo
   * @return
   */
  @SuppressWarnings("unchecked")
  private Object[] getParams(
      HttpServletRequest request,
      HttpServletResponse response,
      MvcMetaInfo mvcMetaInfo,
      Object controllerReturn) {
    byte[] methodParam = mvcMetaInfo.getMethodParam();
    ParamMetaInfo[] paramMetaInfos = mvcMetaInfo.getParamMetaInfos();
    Object[] p = new Object[methodParam.length];
    boolean firstString = true;
    for (int i = 0; i < p.length; i++) {
      switch (methodParam[i]) {
        case MethodParam.REQUEST:
          p[i] = request;
          break;
        case MethodParam.RESPONSE:
          p[i] = response;
          break;
        case MethodParam.HTTP_PARAM:
          // 请求参数封装到javabean
          Enumeration<String> enumeration = request.getParameterNames();
          ParamMetaInfo paramMetaInfo = paramMetaInfos[i];
          p[i] = paramMetaInfo.newParamInstance();

          // 把http参数赋值给参数对象
          while (enumeration.hasMoreElements()) {
            String httpParamName = enumeration.nextElement();
            String paramValue = request.getParameter(httpParamName);
            paramMetaInfo.setParam(p[i], httpParamName, paramValue);
          }
          if (VerifyUtils.isNotEmpty(paramMetaInfo.getAttribute())) {
            request.setAttribute(paramMetaInfo.getAttribute(), p[i]);
          }
          break;
        case MethodParam.CONTROLLER_RETURN:
          p[i] = firstString ? (String) controllerReturn : null;
          firstString = false;
          break;
      }
    }
    return p;
  }