Java WebMvcLinkBuilder无法始终处理SuseFilPath=true

Java WebMvcLinkBuilder无法始终处理SuseFilPath=true,java,spring,spring-boot,spring-mvc,spring-hateoas,Java,Spring,Spring Boot,Spring Mvc,Spring Hateoas,我遇到的问题与中的问题几乎相同,但使用较新的生成器,即WebMvcLinkBuilder 简言之: rest servlet映射到/rest/v1/*,如下所示: @Configuration @EnableWebMvc @ImportAutoConfiguration(ServletWebServerFactoryAutoConfiguration.class) public class ServletConfig implements WebMvcConfigurer {

我遇到的问题与中的问题几乎相同,但使用较新的生成器,即
WebMvcLinkBuilder

简言之:

  • rest servlet映射到
    /rest/v1/*
    ,如下所示:

      @Configuration
      @EnableWebMvc
      @ImportAutoConfiguration(ServletWebServerFactoryAutoConfiguration.class)
      public class ServletConfig implements WebMvcConfigurer {
    
          @Bean
          public ServletContextInitializer servletContextInitializer() {
              return servletContext -> {
                  // REST v1 servlet
                  AnnotationConfigWebApplicationContext restContextV2 = new AnnotationConfigWebApplicationContext();
                  restContextV2.register(RestConfig.class);
                  ServletRegistration.Dynamic restServletV2 = servletContext.addServlet("rest", new DispatcherServlet(restContextV2));
                  restServletV2.setLoadOnStartup(1);
                  restServletV2.addMapping("/rest/v1/*");
              };
          }
    
      }
    
  • RestConfig

  • 文档控制器映射到
    /rest/v1/documents

然后,对于
/rest/v1/documents
的帖子,我收到一个如下链接:
http://localhost:8080/rest/v1/rest/v1/documents
(注意加倍servlet映射)

链接到完整示例:


我是不是误解了什么,或者这实际上是一个bug?

你对此有什么答案吗?我没有。在项目页面上创建了,但到目前为止没有响应。我们不久前放弃了这个,将两个API合并为一个。你对此有什么答案吗?我没有。在项目页面上创建了,但到目前为止没有响应。我们不久前放弃了这一点,将两个API合并为一个。