idea 中 对于属性<clinit>, 注释org.springframework.web.bind.annotation.CrossOrigin缺少值
来源:互联网 发布:public cms 编辑:程序博客网 时间:2024/05/22 17:00
在idea 中web工程添加了@CrossOrigin ,启动项目后,程序编译报错,提示 “对于属性<clinit>, 注释org.springframework.web.bind.annotation.CrossOrigin缺少值.”。
今天 经过一番摸索,把jdk版本和Java语言级别都调成1.8,这个就能编译通过
Spring MVC 从4.2版本开始增加了对CORS的支持
在spring MVC 中增加CORS支持非常简单,可以配置全局的规则,也可以使用@CrossOrigin
注解进行细粒度的配置。
使用@CrossOrigin
注解
先通过源码看看该注解支持的属性
@Target({ ElementType.METHOD, ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface CrossOrigin { String[] DEFAULT_ORIGINS = { "*" }; String[] DEFAULT_ALLOWED_HEADERS = { "*" }; boolean DEFAULT_ALLOW_CREDENTIALS = true; long DEFAULT_MAX_AGE = 1800; /** * 同origins属性一样 */ @AliasFor("origins") String[] value() default {}; /** * 所有支持域的集合,例如"http://domain1.com"。 * <p>这些值都显示在请求头中的Access-Control-Allow-Origin * "*"代表所有域的请求都支持 * <p>如果没有定义,所有请求的域都支持 * @see #value */ @AliasFor("value") String[] origins() default {}; /** * 允许请求头重的header,默认都支持 */ String[] allowedHeaders() default {}; /** * 响应头中允许访问的header,默认为空 */ String[] exposedHeaders() default {}; /** * 请求支持的方法,例如"{RequestMethod.GET, RequestMethod.POST}"}。 * 默认支持RequestMapping中设置的方法 */ RequestMethod[] methods() default {}; /** * 是否允许cookie随请求发送,使用时必须指定具体的域 */ String allowCredentials() default ""; /** * 预请求的结果的有效期,默认30分钟 */ long maxAge() default -1; }
阅读全文
0 0
- idea 中 对于属性<clinit>, 注释org.springframework.web.bind.annotation.CrossOrigin缺少值
- 对于属性<clinit>, 注释org.springframework.web.bind.annotation.CrossOrigin缺少值
- SpringMVC注解-org.springframework.web.bind.annotation
- org.springframework.web.bind.annotation 注解详解
- org.springframework.web.bind.annotation.RequestMapping
- Spring中org.springframework.beans.factory.support.DefaultListableBeanFactory.<clinit>解决方法.
- Idea中ClassNotFoundException: org.springframework.web.filter.CharacterEncodingFilter
- org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
- org.springframework.web.bind.MissingServletRequestParameterException: Required Long parameter 'label
- Spring MVC org.springframework.web.bind.MissingServletRequestParameterException解决办法
- Spring MVC org.springframework.web.bind.MissingServletRequestParameterException解决办法
- 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0'
- org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver: method <init>()V
- 报org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver: method <init>()
- 废弃的org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
- Intellij IDEA 启动项目ClassNotFoundException:org.springframework.web.context.ContextLoaderListener
- intellij idea: Error configuring listener org.springframework.web.context.ContextLoaderListener
- idea关于找不到包的问题,比如:Java:程序包org.springframework.beans.factory.annotation不存在
- 一张图看懂开源许可协议,开源许可证GPL、BSD、MIT、Mozilla、Apache和LGPL的区别
- java中ajax遇到的跨域问题处理
- C#基础复习
- 数据库查询近七天的数据
- TensorFlow 多 GPU 处理并行数据
- idea 中 对于属性<clinit>, 注释org.springframework.web.bind.annotation.CrossOrigin缺少值
- MyBatis实战——resultMap,resultType简介,关联对象
- python中pip安装速度慢的问题
- vmware下设置host-only方式上网----本人亲自测试成功
- Android Studio的Appium的JAVA测试用例
- codeforces679B Bear and Tower of Cubes【DFS】
- Linux的nginx环境的vue 部署
- vue轮播图的实现
- IntelliJ 代码颜色含义