Package org.springframework.web.bind.annotation

Examples of org.springframework.web.bind.annotation.RequestMapping


    handlerTypes.add(handlerType);
    handlerTypes.addAll(Arrays.asList(handlerType.getInterfaces()));
    for (Class<?> currentHandlerType : handlerTypes) {
      ReflectionUtils.doWithMethods(currentHandlerType, new ReflectionUtils.MethodCallback() {
        public void doWith(Method method) {
          RequestMapping mapping = AnnotationUtils.findAnnotation(method, RequestMapping.class);
          if (mapping != null) {
            String[] mappedPatterns = mapping.value();
            if (mappedPatterns.length > 0) {
              for (String mappedPattern : mappedPatterns) {
                if (!hasTypeLevelMapping && !mappedPattern.startsWith("/")) {
                  mappedPattern = "/" + mappedPattern;
                }
View Full Code Here


   * Validate the given annotated handler against the current request.
   * @see #validateMapping
   */
  @Override
  protected void validateHandler(Object handler, HttpServletRequest request) throws Exception {
    RequestMapping mapping = this.cachedMappings.get(handler.getClass());
    if (mapping == null) {
      mapping = AnnotationUtils.findAnnotation(handler.getClass(), RequestMapping.class);
    }
    if (mapping != null) {
      validateMapping(mapping, request);
View Full Code Here

  public MethodInfo(final Class<?> clazz, final Method method) {

    this.method = method;

    RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
    if (methodAnnotation != null) {

      RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

      String path = null;
      if (hasValue(classAnnotation)) {
        path = classAnnotation.value()[0];
      }

      if (hasValue(methodAnnotation)) {
        String methodPath = methodAnnotation.value()[0];
        if (path != null) {
View Full Code Here

  private boolean isValidFormPostMethod(final Class<?> clazz, final Method method) {
    if (AnnotationUtils.findAnnotation(clazz, Controller.class) == null) {
      return false;
    }

    RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);

    if (methodAnnotation == null) {
      return false;
    }

    RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

    boolean hasValue = false;

    if (classAnnotation != null) {
      hasValue = (classAnnotation.value() != null && classAnnotation.value().length > 0);
    }

    if (!hasValue) {
      hasValue = (methodAnnotation.value() != null && methodAnnotation.value().length > 0);
    }
View Full Code Here

      }
    }
    else {
      if (method.getReturnType().equals(Void.TYPE)) {

        RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method,
            RequestMapping.class);
        RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz,
            RequestMapping.class);

        String path = null;
        if (hasValue(classAnnotation)) {
          path = classAnnotation.value()[0];
        }

        if (hasValue(methodAnnotation)) {
          String methodPath = methodAnnotation.value()[0];
          if (path != null) {
View Full Code Here

   * Build the redirect URL
   * @param request the HTTP servlet request
   * @return a redirect URL
   */
  private String buildRedirectUrl(HttpServletRequest request) {
    RequestMapping methodRequestMapping = AnnotationUtils.findAnnotation(this.handlerMethod, RequestMapping.class);
    RequestMapping typeLevelRequestMapping = AnnotationUtils.findAnnotation(this.handler.getClass(),
        RequestMapping.class);
    Assert.state(methodRequestMapping != null, "The handler method must declare @RequestMapping annotation");
    Assert.state(methodRequestMapping.value().length == 1,
        "@RequestMapping must have a single value to be mapped to a URL");
    Assert.state(typeLevelRequestMapping == null || typeLevelRequestMapping.value().length == 1,
        "@RequestMapping on handler class must have a single value to be mapped to a URL");
    String url = this.context.getDispatcherServletPath();
    if (url == null) {
      url = request.getServletPath();
    }
    if (typeLevelRequestMapping != null) {
      url += typeLevelRequestMapping.value()[0];
    }

    PathMatcher pathMatcher = this.context.getPathMatcher();
    if (pathMatcher == null) {
      pathMatcher = new AntPathMatcher();
View Full Code Here

      Class<?> handlerType = ClassUtils.getUserClass(handler);
      HandlerMethodResolver resolver = new HandlerMethodResolver();
      resolver.init(handlerType);

      String[] typeMappings = null;
      RequestMapping typeMapping = AnnotationUtils.findAnnotation(handlerType, RequestMapping.class);
      if (typeMapping != null) {
        typeMappings = typeMapping.value();
      }

      Set<Method> handlerMethods = resolver.getHandlerMethods();
      for (Method method : handlerMethods) {

        RequestMapping mapping = method.getAnnotation(RequestMapping.class);

        Collection<String> computedMappings = new HashSet<String>();
        if (typeMappings != null) {
          computedMappings.addAll(Arrays.asList(typeMappings));
        }

        for (String path : mapping.value()) {
          if (typeMappings != null) {
            for (String parent : computedMappings) {
              if (parent.endsWith("/")) {
                parent = parent.substring(0, parent.length() - 1);
              }
              computedMappings.add(parent + path);
            }
          }
          else {
            computedMappings.add(path);
          }
        }

        logger.debug("Analysing mappings for method:" + method.getName() + ", key:" + key
            + ", computed mappings: " + computedMappings);
        if (computedMappings.contains(key)) {
          RequestMethod[] methods = mapping.method();
          if (methods != null && methods.length > 0) {
            for (RequestMethod requestMethod : methods) {
              logger.debug("Added explicit mapping for path=" + key + "to RequestMethod=" + requestMethod);
              result.add(new ResourceInfo(key, requestMethod));
            }
View Full Code Here

  public MethodInfo(final Class<?> clazz, final Method method) {

    this.method = method;

    RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
    if (methodAnnotation != null) {

      RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

      String path = null;
      if (hasValue(classAnnotation)) {
        path = classAnnotation.value()[0];
      }

      if (hasValue(methodAnnotation)) {
        String methodPath = methodAnnotation.value()[0];
        if (path != null) {
View Full Code Here

  private boolean isValidFormPostMethod(final Class<?> clazz, final Method method) {
    if (AnnotationUtils.findAnnotation(clazz, Controller.class) == null) {
      return false;
    }

    RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);

    if (methodAnnotation == null) {
      return false;
    }

    RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

    boolean hasValue = false;

    if (classAnnotation != null) {
      hasValue = (classAnnotation.value() != null && classAnnotation.value().length > 0);
    }

    if (!hasValue) {
      hasValue = (methodAnnotation.value() != null && methodAnnotation.value().length > 0);
    }
View Full Code Here

  public MethodInfo(final Class<?> clazz, final Method method) {

    this.method = method;

    RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
    if (methodAnnotation != null) {

      RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

      String path = null;
      if (hasValue(classAnnotation)) {
        path = classAnnotation.value()[0];
      }

      if (hasValue(methodAnnotation)) {
        String methodPath = methodAnnotation.value()[0];
        if (path != null) {
View Full Code Here

TOP

Related Classes of org.springframework.web.bind.annotation.RequestMapping

Copyright © 2018 www.massapicom. 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.