지나가듯 기록.

spring 3.2 에서 추가됨.

업무 특성이나 기존 querystring으로 처리가능하기 때문인지
접해보지 못함.

여러리소스 및 하위리소스에 대한 복잡한 쿼리를 만드는데 적합하다고..
GraphQL 같은 것에서는 Json으로 계층 하위리소스 조회 가능하지않나? -_-

실 업무에 적용해본적은 없으니 일단 기록만
(구글맵의 좌표값으로 이런형식이 사용됫던것 같기두 하고..)

The URI specification RFC 3986 defines the possibility of including name-value pairs within path segments. There is no specific term used in the spec. The general “URI path parameters” could be applied although the more unique “Matrix URIs”, originating from an old post by Tim Berners-Lee, is also frequently used and fairly well known. Within Spring MVC these are referred to as matrix variables.

Matrix variables can appear in any path segment, each matrix variable separated with a “;” (semicolon). For example: "/cars;color=red;year=2012". Multiple values may be either "," (comma) separated "color=red,green,blue" or the variable name may be repeated "color=red;color=green;color=blue".

If a URL is expected to contain matrix variables, the request mapping pattern must represent them with a URI template. This ensures the request can be matched correctly regardless of whether matrix variables are present or not and in what order they are provided.

Below is an example of extracting the matrix variable “q”:

Since all path segments may contain matrix variables, in some cases you need to be more specific to identify where the variable is expected to be:

A matrix variable may be defined as optional and a default value specified:

All matrix variables may be obtained in a Map:

Note that to enable the use of matrix variables, you must set the removeSemicolonContent property ofRequestMappingHandlerMapping to false. By default it is set to false.

In the MVC namespace, the `mvc:annotation-driven` element has an `enableMatrixVariables` attribute that should be set to `true`. By default it is set to `false`.

Written by

엘디는 사랑입니다.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store