java自訂註解
淡淡烟草味
淡淡烟草味 2017-06-14 10:52:01
0
2
844

例如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

@Mapping

public @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 {};

}

###為什麼就可以將請求 路由進來啊 實作程式碼在哪裡呢 什麼原理啊? ? ? ###
淡淡烟草味
淡淡烟草味

全部回覆(2)
巴扎黑

如果不了解註解相關的知識,可以了解一下註解知識 1、文章1,2、文章2,這兩篇講解的還不錯。之後可以百度一下spring mvc requestmapping 原始碼解讀,網路上的文章還蠻多的。源碼目前還沒讀過,不過基本的原理應該也是透過反射獲取到對應的配置,再根據配置進行請求路由。具體的是怎麼根據反射取得對應配置的還是要去讀一下原始碼。

習慣沉默

/a/11...

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!