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 {};
}
為什么就可以將請求 路由進(jìn)來啊 實(shí)現(xiàn)代碼在哪兒呢 什么原理啊???
問題解答
回答1:如果不了解注解相關(guān)的知識,可以了解一下注解知識 1、文章1,2、文章2,這兩篇講解的還不錯(cuò)。之后可以百度一下spring mvc requestmapping 源碼解讀,網(wǎng)上的文章還是蠻多的。源碼目前還沒有讀過,不過基本的原理應(yīng)該也是通過反射獲取到相應(yīng)的配置,再根據(jù)配置進(jìn)行請求路由。具體的是怎么根據(jù)反射獲取相應(yīng)配置的還是要去讀一下源碼。
回答2:/a/11...
相關(guān)文章:
1. [python2]local variable referenced before assignment問題2. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時(shí)間會(huì)消失是什么情況?3. javascript - js setTimeout在雙重for循環(huán)中如何使用?4. javascript - 我的站點(diǎn)貌似被別人克隆了, google 搜索特定文章,除了域名不一樣,其他的都一樣,如何解決?5. python - 如何判斷字符串為企業(yè)注冊名稱6. php - 微信開發(fā)驗(yàn)證服務(wù)器有效性7. python中怎么對列表以區(qū)間進(jìn)行統(tǒng)計(jì)?8. javascript - 求幫助 , ATOM不顯示界面!!!!9. html - 爬蟲時(shí)出現(xiàn)“DNS lookup failed”,打開網(wǎng)頁卻沒問題,這是什么情況?10. html - 移動(dòng)端radio無法選中
