|
对于最新稳定版本,请使用 Spring Boot 4.0.4! |
映射(mappings)
mappings 端点提供有关应用程序请求映射的信息。
检索映射
要获取映射信息,请向 GET 发送一个 /actuator/mappings 请求,如下列基于 curl 的示例所示:
$ curl 'http://localhost:37509/actuator/mappings' -i -X GET \
-H 'accept-encoding: gzip' \
-H 'user-agent: ReactorNetty/1.2.16' \
-H 'accept: */*'
生成的响应类似于以下内容:
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Transfer-Encoding: chunked
Date: Thu, 19 Mar 2026 11:01:23 GMT
Content-Length: 5836
{
"contexts" : {
"application" : {
"mappings" : {
"dispatcherServlets" : {
"dispatcherServlet" : [ {
"handler" : "Actuator root web endpoint",
"predicate" : "{GET [/actuator], produces [application/vnd.spring-boot.actuator.v3+json || application/vnd.spring-boot.actuator.v2+json || application/json]}",
"details" : {
"handlerMethod" : {
"className" : "org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.WebMvcLinksHandler",
"name" : "links",
"descriptor" : "(Ljakarta/servlet/http/HttpServletRequest;Ljakarta/servlet/http/HttpServletResponse;)Ljava/util/Map;"
},
"requestMappingConditions" : {
"consumes" : [ ],
"headers" : [ ],
"methods" : [ "GET" ],
"params" : [ ],
"patterns" : [ "/actuator" ],
"produces" : [ {
"mediaType" : "application/vnd.spring-boot.actuator.v3+json",
"negated" : false
}, {
"mediaType" : "application/vnd.spring-boot.actuator.v2+json",
"negated" : false
}, {
"mediaType" : "application/json",
"negated" : false
} ]
}
}
}, {
"handler" : "Actuator web endpoint 'mappings'",
"predicate" : "{GET [/actuator/mappings], produces [application/vnd.spring-boot.actuator.v3+json || application/vnd.spring-boot.actuator.v2+json || application/json]}",
"details" : {
"handlerMethod" : {
"className" : "org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.OperationHandler",
"name" : "handle",
"descriptor" : "(Ljakarta/servlet/http/HttpServletRequest;Ljava/util/Map;)Ljava/lang/Object;"
},
"requestMappingConditions" : {
"consumes" : [ ],
"headers" : [ ],
"methods" : [ "GET" ],
"params" : [ ],
"patterns" : [ "/actuator/mappings" ],
"produces" : [ {
"mediaType" : "application/vnd.spring-boot.actuator.v3+json",
"negated" : false
}, {
"mediaType" : "application/vnd.spring-boot.actuator.v2+json",
"negated" : false
}, {
"mediaType" : "application/json",
"negated" : false
} ]
}
}
}, {
"handler" : "org.springframework.boot.actuate.autoconfigure.web.mappings.MappingsEndpointServletDocumentationTests$TestConfiguration$$Lambda$2563/0x00007f6894da5b18@26abeb8b",
"predicate" : "(GET && /foo)",
"details" : {
"handlerFunction" : {
"className" : "org.springframework.boot.actuate.autoconfigure.web.mappings.MappingsEndpointServletDocumentationTests$TestConfiguration$$Lambda$2563/0x00007f6894da5b18"
}
}
}, {
"handler" : "org.springframework.boot.actuate.autoconfigure.web.mappings.MappingsEndpointServletDocumentationTests$ExampleController#example()",
"predicate" : "{POST [/], params [a!=alpha], headers [X-Custom=Foo], consumes [application/json || !application/xml], produces [text/plain]}",
"details" : {
"handlerMethod" : {
"className" : "org.springframework.boot.actuate.autoconfigure.web.mappings.MappingsEndpointServletDocumentationTests.ExampleController",
"name" : "example",
"descriptor" : "()Ljava/lang/String;"
},
"requestMappingConditions" : {
"consumes" : [ {
"mediaType" : "application/json",
"negated" : false
}, {
"mediaType" : "application/xml",
"negated" : true
} ],
"headers" : [ {
"name" : "X-Custom",
"value" : "Foo",
"negated" : false
} ],
"methods" : [ "POST" ],
"params" : [ {
"name" : "a",
"value" : "alpha",
"negated" : true
} ],
"patterns" : [ "/" ],
"produces" : [ {
"mediaType" : "text/plain",
"negated" : false
} ]
}
}
}, {
"handler" : "ResourceHttpRequestHandler [classpath [META-INF/resources/webjars/]]",
"predicate" : "/webjars/**"
}, {
"handler" : "ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]",
"predicate" : "/**"
} ]
},
"servletFilters" : [ {
"servletNameMappings" : [ ],
"urlPatternMappings" : [ "/*" ],
"name" : "requestContextFilter",
"className" : "org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter"
}, {
"servletNameMappings" : [ ],
"urlPatternMappings" : [ "/*" ],
"name" : "formContentFilter",
"className" : "org.springframework.boot.web.servlet.filter.OrderedFormContentFilter"
} ],
"servlets" : [ {
"mappings" : [ "/" ],
"name" : "dispatcherServlet",
"className" : "org.springframework.web.servlet.DispatcherServlet"
} ]
}
}
}
}
响应结构
响应包含应用程序映射的详细信息。 响应中包含的项目取决于 Web 应用程序的类型(响应式或基于 Servlet)。 下表描述了响应中常见元素的结构:
| 路径 | 类型 | <description> </description> |
|---|---|---|
|
|
按 ID 键索引的应用程序上下文。 |
|
|
上下文中的映射,按映射类型作为键。 |
|
|
调度器Servlet映射(如果有的话)。 |
|
|
Servlet 过滤器映射(如果有)。 |
|
|
Servlet 映射(如果有的话)。 |
|
|
调度器处理器映射(如果有的话)。 |
|
|
父应用上下文的 ID(如果有的话)。 |
以下各节描述了可在 contexts.*.mappings 中找到的条目。
Dispatcher Servlets 响应结构
使用 Spring MVC 时,响应中会包含位于 DispatcherServlet 下的所有 contexts.*.mappings.dispatcherServlets 请求映射的详细信息。
下表描述了响应中该部分的结构:
| 路径 | 类型 | <description> </description> |
|---|---|---|
|
|
按 Dispatcher Servlet Bean 名称索引的 Dispatcher Servlet 映射(如果有的话)。 |
|
|
有关映射的额外实现特定细节。可选。 |
|
|
映射的处理器。 |
|
|
映射的谓词。 |
|
|
处理此映射请求的函数(如果有的话)的详细信息。 |
|
|
函数所属类的完整限定名。 |
|
|
处理对此映射的请求的方法的详细信息(如果有的话)。 |
|
|
方法所在类的完全限定名称。 |
|
|
方法的名称。 |
|
|
根据《Java语言规范》所指定的方法描述符。 |
|
|
请求映射条件的详细信息。 |
|
|
consumes 条件的详细信息 |
|
|
所消费的媒体类型。 |
|
|
媒体类型是否被否定。 |
|
|
头部条件的详细信息。 |
|
|
标头的名称。 |
|
|
请求头的必需值(如果有的话)。 |
|
|
该值是否被取反。 |
|
|
所处理的 HTTP 方法。 |
|
|
参数条件的详细信息。 |
|
|
参数的名称。 |
|
|
参数的必需值(如果有的话)。 |
|
|
该值是否被取反。 |
|
|
用于标识由该映射处理的路径的模式。 |
|
|
produces 条件的详细信息。 |
|
|
生成的媒体类型。 |
|
|
媒体类型是否被否定。 |
Servlets 响应结构
使用 Servlet 堆栈时,响应中会包含位于 Servlet 下的所有 contexts.*.mappings.servlets 映射的详细信息。
下表描述了响应中该部分的结构:
| 路径 | 类型 | <description> </description> |
|---|---|---|
|
|
Servlet 的映射。 |
|
|
Servlet 的名称。 |
|
|
Servlet 的类名 |
Servlet 过滤器响应结构
使用 Servlet 堆栈时,响应中会包含位于 Filter 下的所有 contexts.*.mappings.servletFilters 映射的详细信息。
下表描述了响应中该部分的结构:
| 路径 | 类型 | <description> </description> |
|---|---|---|
|
|
过滤器所映射到的 Servlet 的名称。 |
|
|
过滤器所映射的URL模式。 |
|
|
过滤器的名称。 |
|
|
过滤器的类名 |
Dispatcher 处理程序响应结构
使用 Spring WebFlux 时,响应中会包含位于 DispatcherHandler 下的所有 contexts.*.mappings.dispatcherHandlers 请求映射的详细信息。
下表描述了响应中该部分的结构:
| 路径 | 类型 | <description> </description> |
|---|---|---|
|
|
调度处理器映射(如果有的话),以调度处理器 Bean 名称为键。 |
|
|
有关映射的额外实现特定细节。可选。 |
|
|
映射的处理器。 |
|
|
映射的谓词。 |
|
|
请求映射条件的详细信息。 |
|
|
consumes 条件的详细信息 |
|
|
所消费的媒体类型。 |
|
|
媒体类型是否被否定。 |
|
|
头部条件的详细信息。 |
|
|
标头的名称。 |
|
|
请求头的必需值(如果有的话)。 |
|
|
该值是否被取反。 |
|
|
所处理的 HTTP 方法。 |
|
|
参数条件的详细信息。 |
|
|
参数的名称。 |
|
|
参数的必需值(如果有的话)。 |
|
|
该值是否被取反。 |
|
|
用于标识由该映射处理的路径的模式。 |
|
|
produces 条件的详细信息。 |
|
|
生成的媒体类型。 |
|
|
媒体类型是否被否定。 |
|
|
处理对此映射的请求的方法的详细信息(如果有的话)。 |
|
|
方法所在类的完全限定名称。 |
|
|
方法的名称。 |
|
|
根据《Java语言规范》所指定的方法描述符。 |
|
|
处理此映射请求的函数(如果有的话)的详细信息。 |
|
|
函数所属类的完整限定名。 |