一.@Retention可以用来修饰注解,是注解的注解,称为元注解。
     Retention注解有一个属性value,是RetentionPolicy类型的,Enum RetentionPolicy是一个枚举类型,

注解按生命周期来划分可分为3类:

1、RetentionPolicy.SOURCE:注解只保留在源文件,当Java文件编译成class文件的时候,注解被遗弃;
2、RetentionPolicy.CLASS:注解被保留到class文件,但jvm加载class文件时候被遗弃,这是默认的生命周期;
3、RetentionPolicy.RUNTIME:注解不仅被保存到class文件中,jvm加载class文件之后,仍然存在;

这3个生命周期分别对应于:Java源文件(.java文件) ---> .class文件 ---> 内存中的字节码。

二。SpringMvc跨域支持

从Spring MVC 4.2 开始增加支持跨域访问

1.在类或方法上增加@CrossOrigin注解

 

origins  : 允许可访问的域列表

  1. List of allowed origins, e.g. "http://domain1.com".
  2. These values are placed in the Access-Control-Allow-Origin header of both the pre-flight response and the actual response. "*" means that all origins are allowed.
  3. If undefined, all origins are allowed.

 maxAge:飞行前响应的缓存持续时间的最大年龄(以秒为单位)。

  1. The maximum age (in seconds) of the cache duration for pre-flight responses.
  2. This property controls the value of the Access-Control-Max-Age header in the pre-flight response.
  3. Setting this to a reasonable value can reduce the number of pre-flight request/response interactions required by the browser. A negative value means undefined.
  4. If undefined, max age is set to 1800 seconds (i.e., 30 minutes).

2.@Controller 和  @RestController的区别?
     官方文档:
    @RestController is a stereotype annotation that combines @ResponseBody and @Controller.
    意思是:
    @RestController注解相当于@ResponseBody + @Controller合在一起的作用。

3.用 @Deprecated注解的程序元素

不鼓励程序员使用这样的元素,通常是因为它很危险或存在更好的选择。

在使用不被赞成的程序元素或在不被赞成的代码中执行重写时,编译器会发出警告。

最新文章

  1. 【学】React的学习之旅3 - 添加事件(onClick)
  2. Android狂记忆
  3. Moqui简介
  4. jQuery Ajax请求提交 后台getParameter接收不到数据
  5. CF 500 C. New Year Book Reading 贪心 简单题
  6. 【POJ 1984】Navigation Nightmare(带权并查集)
  7. js事件的方法
  8. 【HDOJ】1716 排列2
  9. python语言磁力搜索引擎源码公开,基于DHT协议
  10. LINQ之路(2):LINQ to SQL本质
  11. 记一次解决curl https证书问题
  12. 直播协议 HTTP-FLV 详解
  13. Algorithm --> 字母重排
  14. hadoop学习大纲
  15. php之array_column 的使用
  16. Android Studio 使用本地gradle配置详解
  17. Oracle数据库重做日志及归档日志的工作原理说明
  18. Java 在匿名内部函数中为外部函数变量赋值的解决方案
  19. # 20155204 2016-2017-2 《Java程序设计》第五周学习总结
  20. 为什么只有一个元素的tuple要加逗号?

热门文章

  1. spring boot 2.x 系列 —— spring boot 整合 kafka
  2. Linux命令之nohup (转)
  3. ELK架构下利用Kafka Group实现Logstash的高可用
  4. Niginx简单的配置
  5. CodeForces 691D:Swaps in Permutation(并查集)
  6. synchronized与ReentrantLock实现共享资源的消费
  7. 基于SpringCloud的Microservices架构实战案例-在线API管理
  8. Spring Boot 2.0 迁移指南
  9. [ZJOI2006]物流运输 题解
  10. 【转载】DOMContentLoaded与load的区别