映射 (mappings)

mappings 端点提供有关应用程序请求映射的信息。

获取映射

要获取映射,向 /actuator/mappings 发送 GET 请求,如下面的基于 curl 的示例所示:

$ curl 'http://localhost:52511/actuator/mappings' -i -X GET \
    -H 'accept-encoding: gzip' \
    -H 'user-agent: ReactorNetty/1.2.6' \
    -H 'accept: */*'

响应结果类似于以下内容:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Transfer-Encoding: chunked
Date: Sun, 25 May 2025 10:03:28 GMT
Content-Length: 5317

{
  "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/lang/Object;"
              },
              "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$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)。 下表描述了响应中常见元素的结构:

Path Type Description

contexts

Object

Application contexts keyed by id.

contexts.*.mappings

Object

Mappings in the context, keyed by mapping type.

contexts.*.mappings.dispatcherServlets

Object

Dispatcher servlet mappings, if any.

contexts.*.mappings.servletFilters

Array

Servlet filter mappings, if any.

contexts.*.mappings.servlets

Array

Servlet mappings, if any.

contexts.*.mappings.dispatcherHandlers

Object

Dispatcher handler mappings, if any.

contexts.*.parentId

String

Id of the parent application context, if any.

contexts.*.mappings 中可能找到的条目在以下章节中描述。

Dispatcher Servlets 响应结构

使用 Spring MVC 时,响应包含 contexts.*.mappings.dispatcherServlets 下任何 DispatcherServlet 请求映射的详细信息。 下表描述了响应此部分的结构:

Path Type Description

*

Array

Dispatcher servlet mappings, if any, keyed by dispatcher servlet bean name.

*.[].details

Object

Additional implementation-specific details about the mapping. Optional.

*.[].handler

String

Handler for the mapping.

*.[].predicate

String

Predicate for the mapping.

*.[].details.handlerMethod

Object

Details of the method, if any, that will handle requests to this mapping.

*.[].details.handlerMethod.className

Varies

Fully qualified name of the class of the method.

*.[].details.handlerMethod.name

Varies

Name of the method.

*.[].details.handlerMethod.descriptor

Varies

Descriptor of the method as specified in the Java Language Specification.

*.[].details.requestMappingConditions

Object

Details of the request mapping conditions.

*.[].details.requestMappingConditions.consumes

Varies

Details of the consumes condition

*.[].details.requestMappingConditions.consumes.[].mediaType

Varies

Consumed media type.

*.[].details.requestMappingConditions.consumes.[].negated

Varies

Whether the media type is negated.

*.[].details.requestMappingConditions.headers

Varies

Details of the headers condition.

*.[].details.requestMappingConditions.headers.[].name

Varies

Name of the header.

*.[].details.requestMappingConditions.headers.[].value

Varies

Required value of the header, if any.

*.[].details.requestMappingConditions.headers.[].negated

Varies

Whether the value is negated.

*.[].details.requestMappingConditions.methods

Varies

HTTP methods that are handled.

*.[].details.requestMappingConditions.params

Varies

Details of the params condition.

*.[].details.requestMappingConditions.params.[].name

Varies

Name of the parameter.

*.[].details.requestMappingConditions.params.[].value

Varies

Required value of the parameter, if any.

*.[].details.requestMappingConditions.params.[].negated

Varies

Whether the value is negated.

*.[].details.requestMappingConditions.patterns

Varies

Patterns identifying the paths handled by the mapping.

*.[].details.requestMappingConditions.produces

Varies

Details of the produces condition.

*.[].details.requestMappingConditions.produces.[].mediaType

Varies

Produced media type.

*.[].details.requestMappingConditions.produces.[].negated

Varies

Whether the media type is negated.

Servlets 响应结构

使用 Servlet 堆栈时,响应包含 contexts.*.mappings.servlets 下任何 Servlet 映射的详细信息。 下表描述了响应此部分的结构:

Path Type Description

[].mappings

Array

Mappings of the servlet.

[].name

String

Name of the servlet.

[].className

String

Class name of the servlet

Servlet Filters 响应结构

使用 Servlet 堆栈时,响应包含 contexts.*.mappings.servletFilters 下任何 Filter 映射的详细信息。 下表描述了响应此部分的结构:

Path Type Description

[].servletNameMappings

Array

Names of the servlets to which the filter is mapped.

[].urlPatternMappings

Array

URL pattern to which the filter is mapped.

[].name

String

Name of the filter.

[].className

String

Class name of the filter

Dispatcher Handlers 响应结构

使用 Spring WebFlux 时,响应包含 contexts.*.mappings.dispatcherHandlers 下任何 DispatcherHandler 请求映射的详细信息。 下表描述了响应此部分的结构:

Path Type Description

*

Array

Dispatcher handler mappings, if any, keyed by dispatcher handler bean name.

*.[].details

Object

Additional implementation-specific details about the mapping. Optional.

*.[].handler

String

Handler for the mapping.

*.[].predicate

String

Predicate for the mapping.

*.[].details.requestMappingConditions

Object

Details of the request mapping conditions.

*.[].details.requestMappingConditions.consumes

Varies

Details of the consumes condition

*.[].details.requestMappingConditions.consumes.[].mediaType

Varies

Consumed media type.

*.[].details.requestMappingConditions.consumes.[].negated

Varies

Whether the media type is negated.

*.[].details.requestMappingConditions.headers

Varies

Details of the headers condition.

*.[].details.requestMappingConditions.headers.[].name

Varies

Name of the header.

*.[].details.requestMappingConditions.headers.[].value

Varies

Required value of the header, if any.

*.[].details.requestMappingConditions.headers.[].negated

Varies

Whether the value is negated.

*.[].details.requestMappingConditions.methods

Varies

HTTP methods that are handled.

*.[].details.requestMappingConditions.params

Varies

Details of the params condition.

*.[].details.requestMappingConditions.params.[].name

Varies

Name of the parameter.

*.[].details.requestMappingConditions.params.[].value

Varies

Required value of the parameter, if any.

*.[].details.requestMappingConditions.params.[].negated

Varies

Whether the value is negated.

*.[].details.requestMappingConditions.patterns

Varies

Patterns identifying the paths handled by the mapping.

*.[].details.requestMappingConditions.produces

Varies

Details of the produces condition.

*.[].details.requestMappingConditions.produces.[].mediaType

Varies

Produced media type.

*.[].details.requestMappingConditions.produces.[].negated

Varies

Whether the media type is negated.

*.[].details.handlerMethod

Object

Details of the method, if any, that will handle requests to this mapping.

*.[].details.handlerMethod.className

String

Fully qualified name of the class of the method.

*.[].details.handlerMethod.name

String

Name of the method.

*.[].details.handlerMethod.descriptor

String

Descriptor of the method as specified in the Java Language Specification.

*.[].details.handlerFunction

Object

Details of the function, if any, that will handle requests to this mapping.

*.[].details.handlerFunction.className

String

Fully qualified name of the class of the function.