简体   繁体   中英

Spring boot with Jetty - config servlet context path

I am using Spring Boot with Jetty. I configure the context-path:

server.servlet.context-path=/test

When accessing http://localhost:8080/test, it doesn't work. But going to http://localhost:8080/test/ works.

Is /test and /test/ different? How can I access http://localhost:8080/test

I think you are looking for something similar to setUseTrailingSlashMatch

Docs:

Whether to match to URLs irrespective of the presence of a trailing slash. If enabled a method mapped to "/users" also matches to "/users/". The default value is true.

Code:

public class Config extends WebMvcConfigurationSupport {

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM