How to match /debug;page=ba as a matrix variable?

22 views Asked by At

I want to match a GET request like this /debug;page=ba. The most intuitive way seems to use matrix variables. So following https://www.baeldung.com/spring-mvc-matrix-variables I added

@Configuration
class WebConfig : WebMvcConfigurer {
    override fun configurePathMatch(configurer: PathMatchConfigurer) {
        val urlPathHelper = UrlPathHelper()
        urlPathHelper.setRemoveSemicolonContent(false)
        configurer.setUrlPathHelper(urlPathHelper)
    }
}

and in my controller

    @RequestMapping("/debug", produces = [MediaType.TEXT_PLAIN_VALUE], method = [RequestMethod.GET])
    @ResponseBody
    fun debug(@MatrixVariable page: String): String {
        return "page: $page"
    }

But this does not work. With curl, I get

$ curl http://localhost:8080/debug;page=10
{"timestamp":"2023-05-29T10:20:55.180+00:00","status":400,"error":"Bad Request","path":"/debug"}

and in the browser

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon May 29 12:23:06 CEST 2023
There was an unexpected error (type=Not Found, status=404).

Why does this still not work?

0

There are 0 answers