簡體   English   中英

Spring Boot with Jetty - 配置 servlet 上下文路徑

[英]Spring boot with Jetty - config servlet context path

我正在使用帶有 Jetty 的 Spring Boot。 我配置上下文路徑:

server.servlet.context-path=/test

訪問http://localhost:8080/test的時候就不行了。 但是去 http://localhost:8080/test/ 可以。

/test 和 /test/ 不同嗎? 如何訪問 http://localhost:8080/test

我認為您正在尋找類似於setUseTrailingSlashMatch的東西

文件:

無論是否存在斜杠,是否匹配 URL。 如果啟用,映射到“/users”的方法也匹配到“/users/”。 默認值是true。

代碼:

public class Config extends WebMvcConfigurationSupport {

    @Override
    protected void configurePathMatch(PathMatchConfigurer configurer) {
        configurer.setUseSuffixPatternMatch(false)
                .setUseTrailingSlashMatch(false);
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM