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. html5 - 如何让H5页面在手机浏览器里和微信全屏显示2. mysql - oracle物化视图和临时表的区别是什么?3. 微信小程序如何加载h5页面4. MYSQL代码执行错误:FUNCTION any_value does not exist5. 网页爬虫 - python+requests 网页重定向求解6. paramiko - Python tempfile生成的文件能不能拷贝到远程服务器?7. python - 能通过CAN控制一部普通的家用轿车吗?8. URL访问有问题啊9. javascript - IOS没有上APP Store如何实现热更新?10. node.js - nodejs开发中常用的连接mysql的库