/** * 设置路径匹配 */ @Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer //设置是否是后缀模式匹配,如"/user"是否匹配"/user.*",默认true .setUseSuffixPatternMatch(false) //设置是否自动后缀路径模式匹配,如"/user"是否匹配"/user/",默认true .setUseTrailingSlashMatch(true); }
/** * {@inheritDoc} */ @Override public final void configurePathMatch(PathMatchConfigurer configurer) { configurer.setUseSuffixPatternMatch(false); xmConfigurePathMatch(configurer); }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { super.configurePathMatch(configurer); configurer.setUseSuffixPatternMatch(false);// /hello/1-2 and /hello/1-2.1 are not same configurer.setUseTrailingSlashMatch(true); // /hello/ and /hello are same }
/** * PathMatchConfigurer 函数让开发人员可以根据需求定制URL路径的匹配规则。 * * @param configurer */ @Override public void configurePathMatch(PathMatchConfigurer configurer) { /** * spring mvc 默认忽略 url 中点"."后面的部分,如 * http://localhost:8080/abc.mm 会直接匹配为 * http://localhost:8080/abc 忽略了 mm * 如果不想忽略,设置 setUseSuffixPatternMatch(false) */ configurer.setUseSuffixPatternMatch(false); }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { //This should make the url case insensitive AntPathMatcher matcher = new AntPathMatcher(); matcher.setCaseSensitive(false); configurer.setPathMatcher(matcher); }
/** * Configure the path match by disabling suffix pattern matching. * * @param configurer the path match configurer. */ @Override public void configurePathMatch(PathMatchConfigurer configurer) { // Turn off suffix pattern matching which will ensure REST URL's that end with periods and some other text get matched in full and not without // the period and the following text suffix. This is due to Spring's extension suffix matching logic that we don't need and don't want // (e.g. .txt could be parsed by a specific handler). configurer.setUseSuffixPatternMatch(false); }
/** * Return a {@link RequestMappingHandlerMapping} ordered at 0 for mapping * requests to annotated controllers. */ @Bean @Override public RequestMappingHandlerMapping requestMappingHandlerMapping() { PathMatchConfigurer configurer = new PathMatchConfigurer(); configurePathMatch(configurer); RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping(); handlerMapping.setOrder(0); handlerMapping.setDetectHandlerMethodsInAncestorContexts(true); handlerMapping.setInterceptors(getInterceptors()); handlerMapping.setContentNegotiationManager(mvcContentNegotiationManager()); if (configurer.isUseSuffixPatternMatch() != null) { handlerMapping.setUseSuffixPatternMatch(configurer.isUseSuffixPatternMatch()); } if (configurer.isUseRegisteredSuffixPatternMatch() != null) { handlerMapping.setUseRegisteredSuffixPatternMatch(configurer.isUseRegisteredSuffixPatternMatch()); } if (configurer.isUseTrailingSlashMatch() != null) { handlerMapping.setUseTrailingSlashMatch(configurer.isUseTrailingSlashMatch()); } if (configurer.getPathMatcher() != null) { handlerMapping.setPathMatcher(configurer.getPathMatcher()); } if (configurer.getUrlPathHelper() != null) { handlerMapping.setUrlPathHelper(configurer.getUrlPathHelper()); } return handlerMapping; }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer.setUseSuffixPatternMatch(false); }
/**Optional. It's only required when handling '.' in @PathVariables which otherwise ignore everything after last '.' in @PathVaidables argument. * It's a known bug in Spring [https://jira.spring.io/browse/SPR-6164], still present in Spring 4.1.7. * This is a workaround for this issue. */ @Override public void configurePathMatch(PathMatchConfigurer matcher) { matcher.setUseRegisteredSuffixPatternMatch(true); }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { // Fix handling of /api/v1/addon/org.openmrs.module.appui (otherwise appui is treated as a file extension) configurer.setUseRegisteredSuffixPatternMatch(true); }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { super.configurePathMatch(configurer); configurer.setUseSuffixPatternMatch(false); }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { AntPathMatcher matcher = new AntPathMatcher(); matcher.setCaseSensitive(false); configurer.setPathMatcher(matcher); }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer.setUseTrailingSlashMatch(false); configurer.setUseSuffixPatternMatch(false); }
@Override public void configurePathMatch(final PathMatchConfigurer configurer) { //configurer.setUseSuffixPatternMatch(false); configurer.setUseTrailingSlashMatch(true); }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer.setUseTrailingSlashMatch(true); }
@Override public void configurePathMatch(final PathMatchConfigurer configurer) { configurer.setUseSuffixPatternMatch(false); configurer.setUseRegisteredSuffixPatternMatch(false); }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { UrlPathHelper urlPathHelper = new UrlPathHelper(); urlPathHelper.setRemoveSemicolonContent(false); configurer.setUrlPathHelper(urlPathHelper); }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { // Spring MVC by default uses the last dot in the URL as file type separator (e.g.: xxx.xml). // To allow domain names as part of the URL we need switch of this behaviour. configurer.setUseSuffixPatternMatch(false); }
@Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer.setUseSuffixPatternMatch(false); configurer.setUseTrailingSlashMatch(true); super.configurePathMatch(configurer); }
@Override public void configurePathMatch(final PathMatchConfigurer configurer) { configurer.setUseRegisteredSuffixPatternMatch(true); }
/** * Helps with configuring HandlerMappings path matching options such as trailing slash match, * suffix registration, path matcher and path helper. * Configured path matcher and path helper instances are shared for: * <ul> * <li>RequestMappings</li> * <li>ViewControllerMappings</li> * <li>ResourcesMappings</li> * </ul> * * @see WebMvcConfigurer#configurePathMatch(org.springframework.web.servlet.config.annotation.PathMatchConfigurer) */ protected abstract void xmConfigurePathMatch(PathMatchConfigurer configurer);
/** * {@inheritDoc} * <p> * Turn off {@literal .} recognition in paths. Needed due to table's name potentially having '.' as character. * * @see <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html">SpringDoc</a> */ @Override public void configurePathMatch(final PathMatchConfigurer configurer) { configurer.setUseSuffixPatternMatch(false); }