如何从RequestHandlerMapping对象中删除mappingRegister

 收藏

我尝试在应用程序的请求映射中自定义路径前缀以优化请求映射路径,现在我已定义ModuleRequestMappingHandlerMapping对象以处理我的自定义请求映射路径。

但是,我遇到了一个问题。访问URL最初是“ / test / mapping”,现在访问URL是“ / aaa / test / mapping”,我想删除源的请求映射。

我应该怎么办?

我从调用方法的unregisterMapping AbstractHandlerMethodMapping。但是只能从自定义ModuleRequestMappingHandlerMapping注销。我想从RequestMappingHandlerMapping取消注册。

 for (Map.Entry<Method, T> entry : methods.entrySet()) {
            Method method = entry.getKey();


 RequestMappingInfo mapping = (RequestMappingInfo) entry.getValue();
        String urlPrefix = nowModuleRequestMappingUrlInfo.getUrlPrefix();

        //Origin handler
        if (StringUtils.isEmpty(urlPrefix)) {
            //Register
            registerHandlerMethod(handler, AopUtils.selectInvocableMethod(method, userType), mapping);
            return;
        }

        //New handler

        //New --- register new mapping info
        //Register
        registerHandlerMethod(handler, AopUtils.selectInvocableMethod(method, userType), mapping);

        //Old --- unregister old mapping info
        //Remove old mapping(if modified)--switch
        if (1 == 1) {
            //Remove prefix
            Predicate<Class<?>> removeObj = pathPrefixes.remove(urlPrefix);
            //Unregister old mapping
            unregisterMapping(this.getMappingForMethod(method, userType));
            //Restore prefix
            pathPrefixes.put(urlPrefix, removeObj);
            //Reset module request mapping url info
            nowModuleRequestMappingUrlInfo.clean();
        }
    }



**I want to unregister mappingRegister from RequestMappingHandlerMapping.Let visit of origin url is fail.there both url is not repeat in visit.**
回复