springmvc url参数和调用方法参数对应原理

来源:互联网 发布:剑网3苏曼莎捏脸数据 编辑:程序博客网 时间:2024/04/29 21:23

parameterNameDiscoverer

作用

解析Method中的参数名称,有以下几种选择方式

1,反射

uses JDK 8’s reflection facilities
for introspecting parameter names (based on the “-parameters” compiler flag).

所以:

  • 要有jdk8支持
  • 编译时必须带上 -parameters参数: Generate metadata for reflection on method parameters(生成元数据以用于方法参数的反射)

2, 本地变量表(LocalVariableTable)

Implementation of {@link ParameterNameDiscoverer} that uses the LocalVariableTable information in the method attributes to discover parameter names. Returns {@code null} if the class file was compiled without debug information.

Uses ObjectWeb’s ASM library for analyzing class files. Each discoverer instance caches the ASM discovered information for each introspected Class, in a thread-safe
manner. It is recommended to reuse ParameterNameDiscoverer instances as far as possible.

3, PrioritizedParameterNameDiscoverer

最常见就是使用这个了,喔喔;
内部实际调用的是

  • StandardReflectionParameterNameDiscoverer 基于反射
  • LocalVariableTableParameterNameDiscoverer 基于LocalVariableTable的ASM字节码实现
0 0
原创粉丝点击