{"id":5740,"date":"2024-08-01T22:47:33","date_gmt":"2024-08-01T14:47:33","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=5740"},"modified":"2024-08-02T16:03:50","modified_gmt":"2024-08-02T08:03:50","slug":"%e6%8e%8c%e6%8f%a1spring-mvc%e4%b8%ad%e8%87%aa%e5%ae%9a%e4%b9%89%e6%b3%a8%e8%a7%a3%e7%9a%84%e5%a6%99%e7%94%a8%ef%bc%8c%e4%b8%ba%e4%bd%a0%e7%9a%84%e4%bb%a3%e7%a0%81%e5%a2%9e%e6%b7%bb%e6%95%b4%e6%b4%81","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/spring-boot\/%e6%8e%8c%e6%8f%a1spring-mvc%e4%b8%ad%e8%87%aa%e5%ae%9a%e4%b9%89%e6%b3%a8%e8%a7%a3%e7%9a%84%e5%a6%99%e7%94%a8%ef%bc%8c%e4%b8%ba%e4%bd%a0%e7%9a%84%e4%bb%a3%e7%a0%81%e5%a2%9e%e6%b7%bb%e6%95%b4%e6%b4%81\/","title":{"rendered":"\u638c\u63e1Spring MVC\u4e2d\u81ea\u5b9a\u4e49\u6ce8\u89e3\u7684\u5999\u7528\uff0c\u4e3a\u4f60\u7684\u4ee3\u7801\u589e\u6dfb\u6574\u6d01\u4e0e\u4f18\u96c5\u3002"},"content":{"rendered":"<div class=\"wxsyncmain\">\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"height: auto !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222517250.jpeg\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-galleryid=\"\" data-imgfileid=\"100000446\" data-ratio=\"0.5712962962962963\" data-s=\"300,640\" data-type=\"jpeg\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"height: auto !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222517250.jpeg\" data-galleryid=\"\" data-imgfileid=\"100000446\" data-ratio=\"0.5712962962962963\" data-s=\"300,640\" data-type=\"jpeg\" data-w=\"1080\" \/><\/noscript><\/p>\n<section style=\"text-align: center; margin-bottom: 8px;\"><\/section>\n<section style=\"text-align: center; margin-bottom: 8px;\"><span style=\"color: #00d5ff;\"><strong><span style=\"color: #00d5ff; font-size: 18px;\">\u6ce8\u89e3\u4ecb\u7ecd<\/span><\/strong><\/span><\/section>\n<p style=\"text-align: left; margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">\u5728Spring MVC\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u81ea\u5b9a\u4e49\u6ce8\u89e3\u6765\u6269\u5c55\u548c\u5b9a\u5236\u5316\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u81ea\u5b9a\u4e49\u6ce8\u89e3\u662f\u4e00\u79cd\u901a\u8fc7Java\u7684\u6ce8\u89e3\u673a\u5236\u5b9a\u4e49\u7684\u7279\u6b8a\u6ce8\u89e3\uff0c\u53ef\u4ee5\u5e94\u7528\u4e8e\u63a7\u5236\u5668\u7c7b\u3001\u65b9\u6cd5\u6216\u8005\u65b9\u6cd5\u53c2\u6570\u4e0a\uff0c\u4ee5\u5b9e\u73b0\u4e0d\u540c\u7684\u529f\u80fd\u548c\u884c\u4e3a\u3002<\/span><\/p>\n<section style=\"text-align: center; margin-bottom: 8px;\"><span style=\"color: #00d5ff;\"><strong><span style=\"color: #00d5ff; font-size: 18px;\">\u53ef\u5b9e\u73b0\u529f\u80fd<\/span><\/strong><\/span><\/section>\n<p style=\"margin-bottom: 8px; margin-left: 8px; margin-right: 8px;\"><span style=\"font-size: 16px;\"><strong>\u8def\u7531\u6620\u5c04\uff1a<\/strong>\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5b9a\u4e49\u6ce8\u89e3\u6765\u6807\u6ce8\u63a7\u5236\u5668\u65b9\u6cd5\uff0c\u4ee5\u6307\u5b9a\u8be5\u65b9\u6cd5\u7684URL\u6620\u5c04\u8def\u5f84\u3002<\/span><\/p>\n<p style=\"margin-bottom: 8px; margin-left: 8px; margin-right: 8px;\"><span style=\"font-size: 16px;\"><strong>\u6743\u9650\u63a7\u5236\uff1a<\/strong>\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5b9a\u4e49\u6ce8\u89e3\uff0c\u7528\u4e8e\u6807\u8bb0\u9700\u8981\u8fdb\u884c\u6743\u9650\u9a8c\u8bc1\u7684\u65b9\u6cd5\uff0c\u4ece\u800c\u5b9e\u73b0\u7b80\u5355\u7684\u6743\u9650\u63a7\u5236\u903b\u8f91\u3002<\/span><\/p>\n<p style=\"margin-bottom: 8px; margin-left: 8px; margin-right: 8px;\"><span style=\"font-size: 16px;\"><strong>\u53c2\u6570\u9a8c\u8bc1\uff1a<\/strong>\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5b9a\u4e49\u6ce8\u89e3\uff0c\u7528\u4e8e\u6807\u8bb0\u65b9\u6cd5\u53c2\u6570\uff0c\u7136\u540e\u7ed3\u5408AOP\u7b49\u6280\u672f\uff0c\u5728\u65b9\u6cd5\u6267\u884c\u524d\u6216\u540e\u8fdb\u884c\u53c2\u6570\u7684\u9a8c\u8bc1\u548c\u6821\u9a8c\u3002<\/span><\/p>\n<p style=\"margin-bottom: 8px; margin-left: 8px; margin-right: 8px;\"><span style=\"font-size: 16px;\"><strong>\u65e5\u5fd7\u8bb0\u5f55\uff1a<\/strong>\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5b9a\u4e49\u6ce8\u89e3\uff0c\u7528\u4e8e\u6807\u8bb0\u9700\u8981\u8fdb\u884c\u65e5\u5fd7\u8bb0\u5f55\u7684\u65b9\u6cd5\uff0c\u4ece\u800c\u5b9e\u73b0\u65e5\u5fd7\u7684\u7edf\u4e00\u5904\u7406\u3002<\/span><\/p>\n<p style=\"margin-bottom: 8px; margin-left: 8px; margin-right: 8px;\"><span style=\"font-size: 16px;\"><strong>\u7f13\u5b58\u63a7\u5236\uff1a<\/strong>\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5b9a\u4e49\u6ce8\u89e3\uff0c\u7528\u4e8e\u6807\u8bb0\u9700\u8981\u8fdb\u884c\u7f13\u5b58\u7ba1\u7406\u7684\u65b9\u6cd5\uff0c\u4ece\u800c\u5b9e\u73b0\u7f13\u5b58\u7684\u81ea\u52a8\u5316\u7ba1\u7406\u3002<\/span><\/p>\n<section style=\"text-align: center; margin-bottom: 8px;\"><span style=\"color: #00d5ff;\"><strong><span style=\"color: #00d5ff; font-size: 18px;\">\u4f7f\u7528\u81ea\u5b9a\u4e49\u6ce8\u89e3\u6d41\u7a0b<\/span><\/strong><\/span><\/section>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\"><strong>\u5b9a\u4e49\u6ce8\u89e3\uff1a<\/strong>\u4f7f\u7528\u6ce8\u89e3\u8bed\u6cd5\uff0c\u5728\u76f8\u5173\u7684\u6ce8\u89e3\u7c7b\u4e0a\u5b9a\u4e49\u81ea\u5b9a\u4e49\u6ce8\u89e3\uff0c\u53ef\u4ee5\u6307\u5b9a\u6ce8\u89e3\u7684\u76ee\u6807\u8303\u56f4\u548c\u5c5e\u6027\u3002<\/span><\/p>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\"><strong>\u6807\u8bb0\u4f7f\u7528\uff1a<\/strong>\u5728\u63a7\u5236\u5668\u7c7b\u3001\u65b9\u6cd5\u6216\u8005\u65b9\u6cd5\u53c2\u6570\u4e0a\u4f7f\u7528\u81ea\u5b9a\u4e49\u6ce8\u89e3\uff0c\u6807\u8bc6\u9700\u8981\u5e94\u7528\u81ea\u5b9a\u4e49\u903b\u8f91\u7684\u5730\u65b9\u3002<\/span><\/p>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\"><strong>\u5904\u7406\u6ce8\u89e3\uff1a<\/strong>\u901a\u8fc7Spring\u7684AOP\u3001\u62e6\u622a\u5668\u7b49\u673a\u5236\uff0c\u5bf9\u6807\u8bb0\u4e86\u7279\u5b9a\u81ea\u5b9a\u4e49\u6ce8\u89e3\u7684\u7c7b\u3001\u65b9\u6cd5\u6216\u8005\u53c2\u6570\u8fdb\u884c\u5904\u7406\uff0c\u5b9e\u73b0\u76f8\u5173\u7684\u529f\u80fd\u3002<\/span><\/p>\n<section style=\"text-align: center; margin-bottom: 8px;\"><span style=\"color: #00d5ff;\"><strong><span style=\"color: #00d5ff; font-size: 18px;\">JDK\u5143\u6ce8\u89e3<\/span><\/strong><\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"kotlin\"><code><span class=\"code-snippet_outer\">@Retention\uff1a\u5b9a\u4e49\u6ce8\u89e3\u7684\u4fdd\u7559\u7b56\u7565<\/span><\/code><code><span class=\"code-snippet_outer\">@Retention(RetentionPolicy.SOURCE)    \/\/\u6ce8\u89e3\u4ec5\u5b58\u5728\u4e8e\u6e90\u7801\u4e2d\uff0c\u5728class\u5b57\u8282\u7801\u6587\u4ef6\u4e2d\u4e0d\u5305\u542b<\/span><\/code><code><span class=\"code-snippet_outer\">@Retention(RetentionPolicy.CLASS)     \/\/\u9ed8\u8ba4\u7684\u4fdd\u7559\u7b56\u7565\uff0c\u6ce8\u89e3\u4f1a\u5728class\u5b57\u8282\u7801\u6587\u4ef6\u4e2d\u5b58\u5728\uff0c\u4f46\u8fd0\u884c\u65f6\u65e0\u6cd5\u83b7\u5f97\uff0c<\/span><\/code><code><span class=\"code-snippet_outer\">@Retention(RetentionPolicy.RUNTIME)\/\/\u6ce8\u89e3\u4f1a\u5728class\u5b57\u8282\u7801\u6587\u4ef6\u4e2d\u5b58\u5728\uff0c\u5728\u8fd0\u884c\u65f6\u53ef\u4ee5\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u5230<\/span><\/code><code><\/code><code><span class=\"code-snippet_outer\">@Target\uff1a\u6307\u5b9a\u88ab\u4fee\u9970\u7684Annotation\u53ef\u4ee5\u653e\u7f6e\u7684\u4f4d\u7f6e(\u88ab\u4fee\u9970\u7684\u76ee\u6807)<\/span><\/code><code><span class=\"code-snippet_outer\">@Target(ElementType.TYPE)                      \/\/\u63a5\u53e3\u3001\u7c7b<\/span><\/code><code><span class=\"code-snippet_outer\">@Target(ElementType.FIELD)                     \/\/\u5c5e\u6027<\/span><\/code><code><span class=\"code-snippet_outer\">@Target(ElementType.METHOD)                    \/\/\u65b9\u6cd5<\/span><\/code><code><span class=\"code-snippet_outer\">@Target(ElementType.PARAMETER)                 \/\/\u65b9\u6cd5\u53c2\u6570<\/span><\/code><code><span class=\"code-snippet_outer\">@Target(ElementType.CONSTRUCTOR)               \/\/\u6784\u9020\u51fd\u6570<\/span><\/code><code><span class=\"code-snippet_outer\">@Target(ElementType.LOCAL_VARIABLE)            \/\/\u5c40\u90e8\u53d8\u91cf<\/span><\/code><code><span class=\"code-snippet_outer\">@Target(ElementType.ANNOTATION_TYPE)           \/\/\u6ce8\u89e3<\/span><\/code><code><span class=\"code-snippet_outer\">@Target(ElementType.PACKAGE)\/\/\u5305<\/span><\/code><code><\/code><code><span class=\"code-snippet_outer\">@Inherited\uff1a\u6307\u5b9a\u88ab\u4fee\u9970\u7684Annotation\u5c06\u5177\u6709\u7ee7\u627f\u6027<\/span><\/code><code><\/code><code><span class=\"code-snippet_outer\">@Documented\uff1a\u6307\u5b9a\u88ab\u4fee\u9970\u7684\u8be5Annotation\u53ef\u4ee5\u88abjavadoc\u5de5\u5177\u63d0\u53d6\u6210\u6587\u6863.<\/span><\/code><\/pre>\n<\/section>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">\u53ef\u80fd\u6709\u7684\u540c\u5b66\u770b\u5230\u8fd9\u4e48\u591a\u6709\u70b9\u8499\uff0c\u5176\u5b9e\u5927\u53ef\u4e0d\u5fc5\uff0c\u5b9e\u9645\u5f00\u53d1\u4e2d\u5e38\u7528\u7684\u4e5f\u5c31\u51e0\u4e2a\u3002\u4e0b\u9762\u6211\u4eec\u4e00\u5757\u6765\u770b\u4e0b\u600e\u4e48\u58f0\u660e\u548c\u4f7f\u7528\u6ce8\u89e3\u3002<\/span><\/p>\n<section style=\"text-align: center; margin-bottom: 8px;\"><span style=\"color: #00d5ff;\"><strong><span style=\"color: #00d5ff; font-size: 18px;\">\u58f0\u660e\u6ce8\u89e3<\/span><\/strong><\/span><\/section>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">\u4f7f\u7528@interface\u5173\u952e\u5b57 \u6765\u58f0\u660e\u6ce8\u89e3<\/span><\/p>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">\u793a\u4f8b\uff1a<\/span><\/p>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">1\u3001\u6ce8\u89e3\u53ef\u7528\u4e8e\u7c7b\u3001\u63a5\u53e3\u3001\u65b9\u6cd5\u3001\u5c5e\u6027\u3001\u65b9\u6cd5\u53c2\u6570\uff1b\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u6dfb\u52a0\u6216\u53bb\u9664<\/span><\/p>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">2\u3001\u59cb\u7ec8\u4e0d\u4f1a\u4e22\u5f03\uff0c\u8fd0\u884c\u671f\u4e5f\u4fdd\u7559\u8be5\u6ce8\u89e3\u3002<\/span><\/p>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">3\u3001\u652f\u6301\u5b50\u7c7b\u7ee7\u627f<\/span><\/p>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">\u8fd4\u56de\u7c7b\u578b\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u81ea\u884c\u5b9a\u4e49\u5373\u53ef<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"typescript\"><code><span class=\"code-snippet_outer\">package com.mkj.publicservice.utils.annotationtest;<\/span><\/code><code><\/code><code><span class=\"code-snippet_outer\">import java.lang.annotation.*;<\/span><\/code><code><\/code><code><span class=\"code-snippet_outer\">\/**<\/span><\/code><code><span class=\"code-snippet_outer\"> * @author: mkj<\/span><\/code><code><span class=\"code-snippet_outer\"> *\/<\/span><\/code><code><span class=\"code-snippet_outer\">@Target({ElementType.TYPE,ElementType.METHOD,ElementType.FIELD,ElementType.PARAMETER})<\/span><\/code><code><span class=\"code-snippet_outer\">@Retention(RetentionPolicy.RUNTIME)<\/span><\/code><code><span class=\"code-snippet_outer\">@Inherited<\/span><\/code><code><span class=\"code-snippet_outer\">public @interface MyAnnotateOne {<\/span><\/code><code><span class=\"code-snippet_outer\">    \/\/\u8fd4\u56de\u7c7b\u578b\u81ea\u5b9a\u4e49\u5373\u53ef<\/span><\/code><code><span class=\"code-snippet_outer\">    String classTest() default \"classTest\";<\/span><\/code><code><span class=\"code-snippet_outer\">    String[] methodTest() default \"methodTest\";<\/span><\/code><code><span class=\"code-snippet_outer\">    String fieldTest() default \"fieldTest\";<\/span><\/code><code><span class=\"code-snippet_outer\">    String parameterTest() default \"parameterTest\";<\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><code><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center; margin-bottom: 8px;\"><span style=\"color: #00d5ff;\"><strong><span style=\"color: #00d5ff; font-size: 18px;\">\u4f7f\u7528\u6ce8\u89e3<\/span><\/strong><\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"kotlin\"><code><span class=\"code-snippet_outer\">@MyAnnotateOne(classTest = \"classTest001\")<\/span><\/code><code><span class=\"code-snippet_outer\">public class AnnotateTest {<\/span><\/code><code><span class=\"code-snippet_outer\">    @MyAnnotateOne(classTest = \"classTest001\",fieldTest = \"fieldTest001\")<\/span><\/code><code><span class=\"code-snippet_outer\">    private String name;<\/span><\/code><code><span class=\"code-snippet_outer\">    @MyAnnotateOne(methodTest = {\"methodTest001\",\"methodTest002\"})<\/span><\/code><code><span class=\"code-snippet_outer\">    public void test001(@MyAnnotateOne(parameterTest = \"parameterTest001\") String params){<\/span><\/code><code><span class=\"code-snippet_outer\">        System.out.println(params);<\/span><\/code><code><span class=\"code-snippet_outer\">    }<\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center; margin-bottom: 8px;\"><span style=\"color: #00d5ff;\"><strong><span style=\"color: #00d5ff; font-size: 18px;\">\u6d4b\u8bd5\u6ce8\u89e3<\/span><\/strong><\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"kotlin\"><code><span class=\"code-snippet_outer\">@Test<\/span><\/code><code><span class=\"code-snippet_outer\">    public void test() throws Exception {<\/span><\/code><code><span class=\"code-snippet_outer\">        \/\/\u83b7\u53d6\u7c7b\u4e0a\u7684\u6ce8\u89e3<\/span><\/code><code><span class=\"code-snippet_outer\">        MyAnnotateOne myAnnotateClass = AnnotateTest.class.getAnnotation(MyAnnotateOne.class);<\/span><\/code><code><span class=\"code-snippet_outer\">        System.out.println(\"\u7c7b\u4e0a\u7684\u6ce8\u89e3--\"+myAnnotateClass.classTest());<\/span><\/code><code><span class=\"code-snippet_outer\">        \/\/\u83b7\u53d6\u5c5e\u6027\u6ce8\u89e3<\/span><\/code><code><span class=\"code-snippet_outer\">        MyAnnotateOne myAnnotateField =AnnotateTest.class.getDeclaredField(\"name\").getAnnotation(MyAnnotateOne.class);<\/span><\/code><code><span class=\"code-snippet_outer\">        System.out.println(\"\u5c5e\u6027\u6ce8\u89e3\"+myAnnotateField.classTest()+\"--\"+myAnnotateField.fieldTest());<\/span><\/code><code><span class=\"code-snippet_outer\">        \/\/\u83b7\u53d6\u65b9\u6cd5\u4e0a\u7684\u6ce8\u89e3<\/span><\/code><code><span class=\"code-snippet_outer\">        MyAnnotateOne myAnnotateMethod =AnnotateTest.class.getMethod(\"test001\",String.class).getAnnotation(MyAnnotateOne.class);<\/span><\/code><code><span class=\"code-snippet_outer\">        String methodStr = \"\";<\/span><\/code><code><span class=\"code-snippet_outer\">        for (String methodVlaue : myAnnotateMethod.methodTest()){<\/span><\/code><code><span class=\"code-snippet_outer\">            methodStr+=methodVlaue+\",\";<\/span><\/code><code><span class=\"code-snippet_outer\">        }<\/span><\/code><code><span class=\"code-snippet_outer\">        System.out.println(\"\u65b9\u6cd5\u4e0a\u7684\u6ce8\u89e3\"+methodStr);<\/span><\/code><code><span class=\"code-snippet_outer\">        \/\/\u83b7\u53d6\u53c2\u6570\u4e0a\u7684\u6ce8\u89e3<\/span><\/code><code><span class=\"code-snippet_outer\">        Parameter[] parameters = AnnotateTest.class.getMethod(\"test001\",String.class).getParameters();<\/span><\/code><code><span class=\"code-snippet_outer\">        for (Parameter parameter : parameters){<\/span><\/code><code><span class=\"code-snippet_outer\">            MyAnnotateOne myAnnotateParameter = parameter.getAnnotation(MyAnnotateOne.class);<\/span><\/code><code><span class=\"code-snippet_outer\">            if (myAnnotateParameter!=null){<\/span><\/code><code><span class=\"code-snippet_outer\">                System.out.println(\"\u53c2\u6570\u4e0a\u7684\u6ce8\u89e3\"+myAnnotateParameter.parameterTest());<\/span><\/code><code><span class=\"code-snippet_outer\">            }<\/span><\/code><code><span class=\"code-snippet_outer\">        }<\/span><\/code><code><\/code><code><span class=\"code-snippet_outer\">    }<\/span><\/code><\/pre>\n<\/section>\n<p style=\"text-align: left; margin-bottom: 8px; margin-left: 8px; margin-right: 8px;\"><span style=\"font-size: 16px;\">\u8f93\u5165\u7ed3\u679c\u5982\u4e0b\uff1a<\/span><\/p>\n<section style=\"text-align: center; margin-bottom: 8px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"height: auto !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222523256.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-galleryid=\"\" data-imgfileid=\"100000445\" data-ratio=\"0.3249097472924188\" data-s=\"300,640\" data-type=\"png\" data-w=\"554\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"height: auto !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222523256.png\" data-galleryid=\"\" data-imgfileid=\"100000445\" data-ratio=\"0.3249097472924188\" data-s=\"300,640\" data-type=\"png\" data-w=\"554\" \/><\/noscript><\/section>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">\u6b64\u5904\u9700\u8bf4\u660e\u4e00\u4e2a\u65b9\u6cd5<\/span><\/p>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">AnnotateTest.class.getMethod(\"test001\",String.class)<\/span><\/p>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"font-size: 16px;\">\u8fd9\u4e2a\u65b9\u6cd5\u9700\u8981\u6ce8\u610f\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u4f60\u65b9\u6cd5\u91cc\u53c2\u6570\u7684\u7c7b\u578b\u3002\u5982\u679c\u662f\u4e24\u4e2aString\u7c7b\u578b\u7684\u53c2\u6570\uff0c\u5c31\u9700\u8981\u8fd9\u4e48\u5199\u3002<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"css\"><code><span class=\"code-snippet_outer\">AnnotateTest.class.getMethod(\"test001\",String.class,String.class)<\/span><\/code><\/pre>\n<\/section>\n<p style=\"margin-left: 8px; margin-right: 8px; margin-bottom: 8px;\"><span style=\"color: #ff0000; font-size: 16px;\">AOP\u914d\u5408\u6ce8\u89e3\u5982\u4f55\u4f7f\u7528\u8bf7\u53c2\u8003\u8fd9\u7bc7\u6587\u7ae0\uff1a<\/span><a href=\"http:\/\/mp.weixin.qq.com\/s?__biz=MzkwMDY4Mzc5OA==&amp;mid=2247484053&amp;idx=1&amp;sn=cf8dd2ddd90abaeba732df3f5b8ec589&amp;chksm=c04103ecf7368afa28dbbcbc2379b0dee419548933a47dd36272db606926956ceb63856b70bb&amp;scene=21#wechat_redirect\" target=\"_blank\" rel=\"noopener\" data-itemshowtype=\"0\" data-linktype=\"2\" rel=\"nofollow\" ><span style=\"font-size: 16px;\">\u638c\u63e1AOP\u5728SpringBoot\u9879\u76ee\u4e2d\u7684\u9ad8\u6548\u96c6\u6210\u4e0e\u4f18\u96c5\u7f16\u7a0b\uff0c\u5b9e\u73b0\u6a21\u5757\u5316\u884c\u4e3a\u5c01\u88c5\u4e0e\u65e5\u5fd7\u7ba1\u7406\u3002<\/span><\/a><\/p>\n<p style=\"margin-top: 8px; margin-bottom: 8px; outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; text-wrap: wrap; background-color: #ffffff; text-align: center;\"><span style=\"outline: 0px; color: #00d5ff;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u4f5c\u8005\u4ecb\u7ecd<\/span><\/strong><\/span><\/p>\n<section style=\"margin-right: 8px; margin-bottom: 8px; margin-left: 8px; outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; text-wrap: wrap; caret-color: rgba(0, 0, 0, 0.9); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); background-color: #ffffff; text-indent: 2em;\"><span style=\"outline: 0px; font-size: 16px;\">90\u5e74\uff0c\u5c5e\u9a6c\uff0c\u4e0a\u73ed\u65cf\uff0c\u6000\u63e3\u68a6\u60f3\uff0c\u575a\u6301\u7528\u5fc3\u5206\u4eab\uff0c\u4e00\u76f4\u60f3\u901a\u8fc7\u81ea\u5df1\u7684\u52aa\u529b\u505a\u51fa\u4e00\u4e9b\u6210\u7ee9\u3002\u4f69\u670d\u901a\u8fc7\u81ea\u5df1\u7684\u575a\u6301\u5b9e\u73b0\u68a6\u60f3\u7684\u4eba\u3002\u76f8\u4fe1\u6ef4\u6c34\u7a7f\u77f3\uff0c\u76f8\u4fe1\u70b9\u6ef4\u7684\u79ef\u7d2f\u7ec8\u6709\u4e00\u5929\u53ef\u4ee5\u6210\u4e3a\u81ea\u5df1\u70ab\u8000\u7684\u8d44\u672c\uff01<\/span><\/section>\n<section class=\"mp_profile_iframe_wrp\"><\/section>\n<p style=\"display: none;\">\n<blockquote><p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7: Java\u6280\u672f\u4ed3\u5e93<\/p><\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u6ce8\u89e3\u4ecb\u7ecd \u5728Spring MVC\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u81ea\u5b9a\u4e49\u6ce8\u89e3\u6765\u6269\u5c55\u548c\u5b9a\u5236\u5316\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u81ea\u5b9a\u4e49\u6ce8\u89e3\u662f\u4e00\u79cd\u901a\u8fc7Java\u7684\u6ce8\u89e3\u673a\u5236\u5b9a\u4e49 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":5730,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-5740","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-boot"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222508197-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222517250.jpeg","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222508197-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222508197-1024x436.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222517250.jpeg","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222508197-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222508197-1024x436.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222508197.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222517250.jpeg","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222517250.jpeg","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222523256.png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222523256.png","id":"image3"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Spring Boot","post_date":"2024-08-01","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":370,"next_post_id":5477,"next_post_title":"SpringBoot \u670d\u52a1\u542f\u52a8\u6162\u6392\u67e5\u601d\u8def","previous_post_id":5378,"previous_post_title":"\u8bf7\u7262\u8bb0SpringBoot\u8fd97\u4e2a\u5f3a\u5927\u7684\u9690\u85cfBean","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/5740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=5740"}],"version-history":[{"count":2,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/5740\/revisions"}],"predecessor-version":[{"id":6439,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/5740\/revisions\/6439"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/5730"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=5740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=5740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=5740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}