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 {};
}
為什么就可以將請求 路由進來啊 實現代碼在哪兒呢 什么原理啊???
問題解答
回答1:如果不了解注解相關的知識,可以了解一下注解知識 1、文章1,2、文章2,這兩篇講解的還不錯。之后可以百度一下spring mvc requestmapping 源碼解讀,網上的文章還是蠻多的。源碼目前還沒有讀過,不過基本的原理應該也是通過反射獲取到相應的配置,再根據配置進行請求路由。具體的是怎么根據反射獲取相應配置的還是要去讀一下源碼。
回答2:/a/11...
相關文章:
1. javascript - 百度echarts series數據更新問題2. MySQL客戶端吃掉了SQL注解?3. java - 我設置了cookie的max age,但是cookie依然在關閉游覽器后消失了4. css3 - [CSS] 動畫效果 3D翻轉bug5. javascript - JS設置Video視頻對象的currentTime時出現了問題,IE,Edge,火狐,都可以設置,反而chrom卻...6. python小白的基礎問題 關于while循環的嵌套7. java固定鍵值轉換,使用枚舉實現字典?8. php自學從哪里開始?9. phpstady在win10上運行10. 求大神幫我看看是哪里寫錯了 感謝細心解答
