java自定义注解
淡淡烟草味
淡淡烟草味 2017-06-14 10:52:01
0
2
746

比如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 {};

}

为什么就可以将请求 路由进来啊 实现代码在哪儿呢 什么原理啊???

淡淡烟草味
淡淡烟草味

Antworte allen(2)
巴扎黑

如果不了解注解相关的知识,可以了解一下注解知识 1、文章1,2、文章2,这两篇讲解的还不错。之后可以百度一下spring mvc requestmapping 源码解读,网上的文章还是蛮多的。源码目前还没有读过,不过基本的原理应该也是通过反射获取到相应的配置,再根据配置进行请求路由。具体的是怎么根据反射获取相应配置的还是要去读一下源码。

習慣沉默

/a/11...

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!