Examples of RequestMapping


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

   * 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

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

      RequestMappingInfo mappingInfo = new RequestMappingInfo();
      ActionMapping actionMapping = AnnotationUtils.findAnnotation(method, ActionMapping.class);
      RenderMapping renderMapping = AnnotationUtils.findAnnotation(method, RenderMapping.class);
      ResourceMapping resourceMapping = AnnotationUtils.findAnnotation(method, ResourceMapping.class);
      EventMapping eventMapping = AnnotationUtils.findAnnotation(method, EventMapping.class);
      RequestMapping requestMapping = AnnotationUtils.findAnnotation(method, RequestMapping.class);
      if (actionMapping != null) {
        mappingInfo.initPhaseMapping(PortletRequest.ACTION_PHASE, actionMapping.value(), actionMapping.params());
      }
      if (renderMapping != null) {
        mappingInfo.initPhaseMapping(PortletRequest.RENDER_PHASE, renderMapping.value(), renderMapping.params());
      }
      if (resourceMapping != null) {
        mappingInfo.initPhaseMapping(PortletRequest.RESOURCE_PHASE, resourceMapping.value(), new String[0]);
      }
      if (eventMapping != null) {
        mappingInfo.initPhaseMapping(PortletRequest.EVENT_PHASE, eventMapping.value(), new String[0]);
      }
      if (requestMapping != null) {
        mappingInfo.initStandardMapping(requestMapping.value(), requestMapping.method(),
            requestMapping.params(), requestMapping.headers());
        if (mappingInfo.phase == null) {
          mappingInfo.phase = determineDefaultPhase(method);
        }
      }
      if (mappingInfo.phase != null) {
View Full Code Here

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

      for (Object handler : handlers) {
        Class<?> controllerClazz = handler.getClass();
        Method[] methods = controllerClazz.getMethods();
        for (Method method : methods) {
          // 查找RequestMapping注解
          RequestMapping requestMapping = method
              .getAnnotation(RequestMapping.class);
          if (requestMapping == null)
            continue;

          for (String methodName : requestMapping.value()) {
            // 内部URL,仅用于 Spring MVC内部匹配到控制器方法
            // 要获取外部URL,请调用WebContext.getBundleMethodUrl方法
            String innerMappingUrl = methodName;
            if (!innerMappingUrl.startsWith("/")) {
              innerMappingUrl = "/" + innerMappingUrl;
            }
            innerMappingUrl = "/" + bundleName + innerMappingUrl;

            RequestMethod[] requestMethods = requestMapping
                .method();
            // 如果方法为空,则映射所有的HTTP方法
            if (requestMethods == null
                || requestMethods.length == 0) {
              requestMethods = RequestMethod.values();
View Full Code Here

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

    public Method resolveHandlerMethod(PortletRequest request, PortletResponse response) throws PortletException {
      String lookupMode = request.getPortletMode().toString();
      Map<RequestMappingInfo, Method> targetHandlerMethods = new LinkedHashMap<RequestMappingInfo, Method>();
      for (Method handlerMethod : getHandlerMethods()) {
        RequestMapping mapping = AnnotationUtils.findAnnotation(handlerMethod, RequestMapping.class);
        RequestMappingInfo mappingInfo = new RequestMappingInfo();
        mappingInfo.modes = mapping.value();
        mappingInfo.params = mapping.params();
        mappingInfo.action = isActionMethod(handlerMethod);
        mappingInfo.render = isRenderMethod(handlerMethod);
        boolean match = false;
        if (mappingInfo.modes.length > 0) {
          for (String mappedMode : mappingInfo.modes) {
View Full Code Here

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

    for (String beanName : beanNames) {
      Class<?> handlerType = context.getType(beanName);
      ListableBeanFactory bf = (context instanceof ConfigurableApplicationContext ?
          ((ConfigurableApplicationContext) context).getBeanFactory() : context);
      GenericBeanFactoryAccessor bfa = new GenericBeanFactoryAccessor(bf);
      RequestMapping mapping = bfa.findAnnotationOnBean(beanName, RequestMapping.class);
      if (mapping != null) {
        String[] modeKeys = mapping.value();
        String[] params = mapping.params();
        boolean registerHandlerType = true;
        if (modeKeys.length == 0 || params.length == 0) {
          registerHandlerType = !detectHandlerMethods(handlerType, beanName, mapping);
        }
        if (registerHandlerType) {
View Full Code Here

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

   */
  protected boolean detectHandlerMethods(Class handlerType, final String beanName, final RequestMapping typeMapping) {
    final Set<Boolean> handlersRegistered = new HashSet<Boolean>(1);
    ReflectionUtils.doWithMethods(handlerType, new ReflectionUtils.MethodCallback() {
      public void doWith(Method method) {
        RequestMapping mapping = method.getAnnotation(RequestMapping.class);
        if (mapping != null) {
          String[] modeKeys = mapping.value();
          if (modeKeys.length == 0) {
            if (typeMapping != null) {
              modeKeys = typeMapping.value();
            }
            else {
              throw new IllegalStateException(
                  "No portlet mode mappings specified - neither at type nor method level");
            }
          }
          String[] params = mapping.params();
          if (typeMapping != null) {
            PortletAnnotationMappingUtils.validateModeMapping(modeKeys, typeMapping.value());
            params = StringUtils.mergeStringArrays(typeMapping.params(), params);
          }
          ParameterMappingPredicate predicate = new ParameterMappingPredicate(params);
View Full Code Here

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

      Map<RequestMappingInfo, Method> targetHandlerMethods = new LinkedHashMap<RequestMappingInfo, Method>();
      Map<RequestMappingInfo, String> targetPathMatches = new LinkedHashMap<RequestMappingInfo, String>();
      String resolvedMethodName = null;
      for (Method handlerMethod : getHandlerMethods()) {
        RequestMappingInfo mappingInfo = new RequestMappingInfo();
        RequestMapping mapping = AnnotationUtils.findAnnotation(handlerMethod, RequestMapping.class);
        mappingInfo.paths = mapping.value();
        if (!hasTypeLevelMapping() || !Arrays.equals(mapping.method(), getTypeLevelMapping().method())) {
          mappingInfo.methods = mapping.method();
        }
        if (!hasTypeLevelMapping() || !Arrays.equals(mapping.params(), getTypeLevelMapping().params())) {
          mappingInfo.params = mapping.params();
        }
        boolean match = false;
        if (mappingInfo.paths.length > 0) {
          for (String mappedPath : mappingInfo.paths) {
            if (isPathMatch(mappedPath, lookupPath)) {
View Full Code Here

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

    ApplicationContext context = getApplicationContext();
    Class<?> handlerType = context.getType(beanName);
    ListableBeanFactory bf = (context instanceof ConfigurableApplicationContext ?
        ((ConfigurableApplicationContext) context).getBeanFactory() : context);
    GenericBeanFactoryAccessor bfa = new GenericBeanFactoryAccessor(bf);
    RequestMapping mapping = bfa.findAnnotationOnBean(beanName, RequestMapping.class);

    if (mapping != null) {
      // @RequestMapping found at type level
      this.cachedMappings.put(handlerType, mapping);
      Set<String> urls = new LinkedHashSet<String>();
      String[] paths = mapping.value();
      if (paths.length > 0) {
        // @RequestMapping specifies paths at type level
        for (String path : paths) {
          addUrlsForPath(urls, path);
        }
View Full Code Here

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

   */
  protected String[] determineUrlsForHandlerMethods(Class<?> handlerType) {
    final Set<String> urls = new LinkedHashSet<String>();
    ReflectionUtils.doWithMethods(handlerType, new ReflectionUtils.MethodCallback() {
      public void doWith(Method method) {
        RequestMapping mapping = method.getAnnotation(RequestMapping.class);
        if (mapping != null) {
          String[] mappedPaths = mapping.value();
          for (int i = 0; i < mappedPaths.length; i++) {
            addUrlsForPath(urls, mappedPaths[i]);
          }
        }
      }
View Full Code Here

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

  /**
   * Validate the given annotated handler against the current request.
   * @see #validateMapping
   */
  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
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.