java自定義注解
問題描述
比如springmvc的requestmapping
//// Source code recreated from a .class file by IntelliJ IDEA// (powered by Fernflower decompiler)//
package org.springframework.web.bind.annotation;
import java.lang.annotation.Documented;import java.lang.annotation.ElementType;import java.lang.annotation.Retention;import java.lang.annotation.RetentionPolicy;import java.lang.annotation.Target;import org.springframework.core.annotation.AliasFor;
@Target({ElementType.METHOD, ElementType.TYPE})@Retention(RetentionPolicy.RUNTIME)@Documented@Mappingpublic @interface RequestMapping {
String name() default '';@AliasFor('path')String[] value() default {};@AliasFor('value')String[] path() default {};RequestMethod[] method() default {};String[] params() default {};String[] headers() default {};String[] consumes() default {};String[] produces() default {};
}
為什么就可以將請求 路由進來啊 實現(xiàn)代碼在哪兒呢 什么原理?????
問題解答
回答1:如果不了解注解相關(guān)的知識,可以了解一下注解知識 1、文章1,2、文章2,這兩篇講解的還不錯。之后可以百度一下spring mvc requestmapping 源碼解讀,網(wǎng)上的文章還是蠻多的。源碼目前還沒有讀過,不過基本的原理應(yīng)該也是通過反射獲取到相應(yīng)的配置,再根據(jù)配置進行請求路由。具體的是怎么根據(jù)反射獲取相應(yīng)配置的還是要去讀一下源碼。
回答2:/a/11...
相關(guān)文章:
1. phpstudy8.1沒集成mysql-front2. 關(guān)docker hub上有些鏡像的tag被標記““This image has vulnerabilities””3. node.js - mongodb查找子對象的名稱為某個值的對象的方法4. docker鏡像push報錯5. Docker for Mac 創(chuàng)建的dnsmasq容器連不上/不工作的問題6. javascript - 在 model里定義的 引用表模型時,model為undefined。7. 運行python程序時出現(xiàn)“應(yīng)用程序發(fā)生異常”的內(nèi)存錯誤?8. javascript - QQ第三方登錄的問題9. 利用IPMI遠程安裝centos報錯!10. html5 - datatables 加載不出來數(shù)據(jù)。

網(wǎng)公網(wǎng)安備