Package org.springframework.web.bind

Examples of org.springframework.web.bind.WebDataBinder.convertIfNecessary()


            "primitive type. Consider declaring it as object wrapper for the corresponding primitive type.");
      }
    }
    WebDataBinder binder = createBinder(webRequest, null, paramName);
    initBinder(handlerForInitBinderCall, paramName, binder, webRequest);
    return binder.convertIfNecessary(paramValue, paramType, methodParam);
  }

  private WebDataBinder resolveModelAttribute(String attrName, MethodParameter methodParam,
      ExtendedModelMap implicitModel, NativeWebRequest webRequest, Object handler) throws Exception {
View Full Code Here


      arg = handleNullValue(namedValueInfo.name, arg, paramType);
    }

    if (binderFactory != null) {
      WebDataBinder binder = binderFactory.createBinder(webRequest, null, namedValueInfo.name);
      arg = binder.convertIfNecessary(arg, paramType, parameter);
    }

    handleResolvedValue(arg, namedValueInfo.name, parameter, mavContainer, webRequest);

    return arg;
View Full Code Here

      }
      paramValue = checkValue(paramName, paramValue, paramType);
    }
    WebDataBinder binder = createBinder(webRequest, null, paramName);
    initBinder(handlerForInitBinderCall, paramName, binder, webRequest);
    return binder.convertIfNecessary(paramValue, paramType, methodParam);
  }

  private Map resolveRequestParamMap(Class<? extends Map> mapType, NativeWebRequest webRequest) {
    Map<String, String[]> parameterMap = webRequest.getParameterMap();
    if (MultiValueMap.class.isAssignableFrom(mapType)) {
View Full Code Here

      }
      headerValue = checkValue(headerName, headerValue, paramType);
    }
    WebDataBinder binder = createBinder(webRequest, null, headerName);
    initBinder(handlerForInitBinderCall, headerName, binder, webRequest);
    return binder.convertIfNecessary(headerValue, paramType, methodParam);
  }

  private Map resolveRequestHeaderMap(Class<? extends Map> mapType, NativeWebRequest webRequest) {
    if (MultiValueMap.class.isAssignableFrom(mapType)) {
      MultiValueMap<String, String> result;
View Full Code Here

      }
      cookieValue = checkValue(cookieName, cookieValue, paramType);
    }
    WebDataBinder binder = createBinder(webRequest, null, cookieName);
    initBinder(handlerForInitBinderCall, cookieName, binder, webRequest);
    return binder.convertIfNecessary(cookieValue, paramType, methodParam);
  }

  /**
   * Resolves the given {@link CookieValue @CookieValue} annotation.
   * <p>Throws an UnsupportedOperationException by default.
View Full Code Here

      pathVarName = getRequiredParameterName(methodParam);
    }
    String pathVarValue = resolvePathVariable(pathVarName, paramType, webRequest);
    WebDataBinder binder = createBinder(webRequest, null, pathVarName);
    initBinder(handlerForInitBinderCall, pathVarName, binder, webRequest);
    return binder.convertIfNecessary(pathVarValue, paramType, methodParam);
  }

  /**
   * Resolves the given {@link PathVariable @PathVariable} annotation.
   * <p>Throws an UnsupportedOperationException by default.
View Full Code Here

      arg = handleNullValue(namedValueInfo.name, arg, paramType);
    }

    if (binderFactory != null) {
      WebDataBinder binder = binderFactory.createBinder(webRequest, null, namedValueInfo.name);
      arg = binder.convertIfNecessary(arg, paramType, parameter);
    }
   
    handleResolvedValue(arg, namedValueInfo.name, parameter, mavContainer, webRequest);

    return arg;
View Full Code Here

                    throw new BindException(binder.getBindingResult());
                }
            }
        }

        target = binder.convertIfNecessary(binder.getTarget(), parameter.getParameterType());
        mavContainer.addAttribute(name, target);

        return target;
    }
View Full Code Here

                if (isSimpleComponent(prefixName)) { //bind simple type
                    Map<String, Object> paramValues = WebUtils.getParametersStartingWith(servletRequest, prefixName);
                    Matcher matcher = INDEX_PATTERN.matcher(prefixName);
                    if(!matcher.matches()) { //处理如 array=1&array=2的情况
                        for (Object value : paramValues.values()) {
                            targetList.add(simpleBinder.convertIfNecessary(value, componentType));
                        }
                    } else //处理如 array[0]=1&array[1]=2的情况
                        int index = Integer.valueOf(matcher.group(1));

                        if (targetList.size() <= index) {
View Full Code Here

                        int index = Integer.valueOf(matcher.group(1));

                        if (targetList.size() <= index) {
                            growCollectionIfNecessary(targetList, index);
                        }
                        targetList.set(index, simpleBinder.convertIfNecessary(paramValues.values(), componentType));
                    }
                } else { //处理如 votes[1].title=votes[1].title&votes[0].title=votes[0].title&votes[0].id=0&votes[1].id=1
                    Object component = null;
                    //先查找老的 即已经在集合中的数据(而不是新添加一个)
                    Matcher matcher = INDEX_PATTERN.matcher(prefixName);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.