@RequestMapping中的注解
在org.springframework.spring-web的jar包中在以下层级下:
org.springframework.web.bind.annotation;
//
// 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})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestMapping(
method = {RequestMethod.GET}
)
public @interface GetMapping {
@AliasFor(
annotation = RequestMapping.class
)
String name() default ""; @AliasFor(
annotation = RequestMapping.class
)
String[] value() default {}; @AliasFor(
annotation = RequestMapping.class
)
String[] path() default {}; @AliasFor(
annotation = RequestMapping.class
)
String[] params() default {}; @AliasFor(
annotation = RequestMapping.class
)
String[] headers() default {}; @AliasFor(
annotation = RequestMapping.class
)
String[] consumes() default {}; @AliasFor(
annotation = RequestMapping.class
)
String[] produces() default {};
}
一些常见的MediaType
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
// package org.springframework.http; import java.io.Serializable;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.InvalidMimeTypeException;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.MimeType.SpecificityComparator; public class MediaType extends MimeType implements Serializable {
private static final long serialVersionUID = 2069937152339670231L;
public static final MediaType ALL = valueOf("*/*");
public static final String ALL_VALUE = "*/*";
public static final MediaType APPLICATION_ATOM_XML = valueOf("application/atom+xml");
public static final String APPLICATION_ATOM_XML_VALUE = "application/atom+xml";
public static final MediaType APPLICATION_FORM_URLENCODED = valueOf("application/x-www-form-urlencoded");
public static final String APPLICATION_FORM_URLENCODED_VALUE = "application/x-www-form-urlencoded";
public static final MediaType APPLICATION_JSON = valueOf("application/json");
public static final String APPLICATION_JSON_VALUE = "application/json";
public static final MediaType APPLICATION_JSON_UTF8 = valueOf("application/json;charset=UTF-8");
public static final String APPLICATION_JSON_UTF8_VALUE = "application/json;charset=UTF-8";
public static final MediaType APPLICATION_OCTET_STREAM = valueOf("application/octet-stream");
public static final String APPLICATION_OCTET_STREAM_VALUE = "application/octet-stream";
public static final MediaType APPLICATION_PDF = valueOf("application/pdf");
public static final String APPLICATION_PDF_VALUE = "application/pdf";
public static final MediaType APPLICATION_PROBLEM_JSON = valueOf("application/problem+json");
public static final String APPLICATION_PROBLEM_JSON_VALUE = "application/problem+json";
public static final MediaType APPLICATION_PROBLEM_JSON_UTF8 = valueOf("application/problem+json;charset=UTF-8");
public static final String APPLICATION_PROBLEM_JSON_UTF8_VALUE = "application/problem+json;charset=UTF-8";
public static final MediaType APPLICATION_PROBLEM_XML = valueOf("application/problem+xml");
public static final String APPLICATION_PROBLEM_XML_VALUE = "application/problem+xml";
public static final MediaType APPLICATION_RSS_XML = valueOf("application/rss+xml");
public static final String APPLICATION_RSS_XML_VALUE = "application/rss+xml";
public static final MediaType APPLICATION_STREAM_JSON = valueOf("application/stream+json");
public static final String APPLICATION_STREAM_JSON_VALUE = "application/stream+json";
public static final MediaType APPLICATION_XHTML_XML = valueOf("application/xhtml+xml");
public static final String APPLICATION_XHTML_XML_VALUE = "application/xhtml+xml";
public static final MediaType APPLICATION_XML = valueOf("application/xml");
public static final String APPLICATION_XML_VALUE = "application/xml";
public static final MediaType IMAGE_GIF = valueOf("image/gif");
public static final String IMAGE_GIF_VALUE = "image/gif";
public static final MediaType IMAGE_JPEG = valueOf("image/jpeg");
public static final String IMAGE_JPEG_VALUE = "image/jpeg";
public static final MediaType IMAGE_PNG = valueOf("image/png");
public static final String IMAGE_PNG_VALUE = "image/png";
public static final MediaType MULTIPART_FORM_DATA = valueOf("multipart/form-data");
public static final String MULTIPART_FORM_DATA_VALUE = "multipart/form-data";
public static final MediaType TEXT_EVENT_STREAM = valueOf("text/event-stream");
public static final String TEXT_EVENT_STREAM_VALUE = "text/event-stream";
public static final MediaType TEXT_HTML = valueOf("text/html");
public static final String TEXT_HTML_VALUE = "text/html";
public static final MediaType TEXT_MARKDOWN = valueOf("text/markdown");
public static final String TEXT_MARKDOWN_VALUE = "text/markdown";
public static final MediaType TEXT_PLAIN = valueOf("text/plain");
public static final String TEXT_PLAIN_VALUE = "text/plain";
public static final MediaType TEXT_XML = valueOf("text/xml");
public static final String TEXT_XML_VALUE = "text/xml";
private static final String PARAM_QUALITY_FACTOR = "q";
public static final Comparator<MediaType> QUALITY_VALUE_COMPARATOR = (mediaType1, mediaType2) -> {
double quality1 = mediaType1.getQualityValue();
double quality2 = mediaType2.getQualityValue();
int qualityComparison = Double.compare(quality2, quality1);
if (qualityComparison != 0) {
return qualityComparison;
} else if (mediaType1.isWildcardType() && !mediaType2.isWildcardType()) {
return 1;
} else if (mediaType2.isWildcardType() && !mediaType1.isWildcardType()) {
return -1;
} else if (!mediaType1.getType().equals(mediaType2.getType())) {
return 0;
} else if (mediaType1.isWildcardSubtype() && !mediaType2.isWildcardSubtype()) {
return 1;
} else if (mediaType2.isWildcardSubtype() && !mediaType1.isWildcardSubtype()) {
return -1;
} else if (!mediaType1.getSubtype().equals(mediaType2.getSubtype())) {
return 0;
} else {
int paramsSize1 = mediaType1.getParameters().size();
int paramsSize2 = mediaType2.getParameters().size();
return paramsSize2 < paramsSize1 ? -1 : (paramsSize2 == paramsSize1 ? 0 : 1);
}
};
public static final Comparator<MediaType> SPECIFICITY_COMPARATOR = new SpecificityComparator<MediaType>() {
protected int compareParameters(MediaType mediaType1, MediaType mediaType2) {
double quality1 = mediaType1.getQualityValue();
double quality2 = mediaType2.getQualityValue();
int qualityComparison = Double.compare(quality2, quality1);
return qualityComparison != 0 ? qualityComparison : super.compareParameters(mediaType1, mediaType2);
}
}; public MediaType(String type) {
super(type);
} public MediaType(String type, String subtype) {
super(type, subtype, Collections.emptyMap());
} public MediaType(String type, String subtype, Charset charset) {
super(type, subtype, charset);
} public MediaType(String type, String subtype, double qualityValue) {
this(type, subtype, Collections.singletonMap("q", Double.toString(qualityValue)));
} public MediaType(MediaType other, Charset charset) {
super(other, charset);
} public MediaType(MediaType other, @Nullable Map<String, String> parameters) {
super(other.getType(), other.getSubtype(), parameters);
} public MediaType(String type, String subtype, @Nullable Map<String, String> parameters) {
super(type, subtype, parameters);
} protected void checkParameters(String attribute, String value) {
super.checkParameters(attribute, value);
if ("q".equals(attribute)) {
value = this.unquote(value);
double d = Double.parseDouble(value);
Assert.isTrue(d >= 0.0D && d <= 1.0D, "Invalid quality value \"" + value + "\": should be between 0.0 and 1.0");
} } public double getQualityValue() {
String qualityFactory = this.getParameter("q");
return qualityFactory != null ? Double.parseDouble(this.unquote(qualityFactory)) : 1.0D;
} public boolean includes(@Nullable MediaType other) {
return super.includes(other);
} public boolean isCompatibleWith(@Nullable MediaType other) {
return super.isCompatibleWith(other);
} public MediaType copyQualityValue(MediaType mediaType) {
if (!mediaType.getParameters().containsKey("q")) {
return this;
} else {
Map<String, String> params = new LinkedHashMap(this.getParameters());
params.put("q", mediaType.getParameters().get("q"));
return new MediaType(this, params);
}
} public MediaType removeQualityValue() {
if (!this.getParameters().containsKey("q")) {
return this;
} else {
Map<String, String> params = new LinkedHashMap(this.getParameters());
params.remove("q");
return new MediaType(this, params);
}
} public static MediaType valueOf(String value) {
return parseMediaType(value);
} public static MediaType parseMediaType(String mediaType) {
MimeType type;
try {
type = MimeTypeUtils.parseMimeType(mediaType);
} catch (InvalidMimeTypeException var4) {
throw new InvalidMediaTypeException(var4);
} try {
return new MediaType(type.getType(), type.getSubtype(), type.getParameters());
} catch (IllegalArgumentException var3) {
throw new InvalidMediaTypeException(mediaType, var3.getMessage());
}
} public static List<MediaType> parseMediaTypes(@Nullable String mediaTypes) {
if (!StringUtils.hasLength(mediaTypes)) {
return Collections.emptyList();
} else {
String[] tokens = StringUtils.tokenizeToStringArray(mediaTypes, ",");
List<MediaType> result = new ArrayList(tokens.length);
String[] var3 = tokens;
int var4 = tokens.length; for(int var5 = 0; var5 < var4; ++var5) {
String token = var3[var5];
result.add(parseMediaType(token));
} return result;
}
} public static List<MediaType> parseMediaTypes(@Nullable List<String> mediaTypes) {
if (CollectionUtils.isEmpty(mediaTypes)) {
return Collections.emptyList();
} else if (mediaTypes.size() == 1) {
return parseMediaTypes((String)mediaTypes.get(0));
} else {
List<MediaType> result = new ArrayList(8);
Iterator var2 = mediaTypes.iterator(); while(var2.hasNext()) {
String mediaType = (String)var2.next();
result.addAll(parseMediaTypes(mediaType));
} return result;
}
} public static List<MediaType> asMediaTypes(List<MimeType> mimeTypes) {
return (List)mimeTypes.stream().map(MediaType::asMediaType).collect(Collectors.toList());
} public static MediaType asMediaType(MimeType mimeType) {
return mimeType instanceof MediaType ? (MediaType)mimeType : new MediaType(mimeType.getType(), mimeType.getSubtype(), mimeType.getParameters());
} public static String toString(Collection<MediaType> mediaTypes) {
return MimeTypeUtils.toString(mediaTypes);
} public static void sortBySpecificity(List<MediaType> mediaTypes) {
Assert.notNull(mediaTypes, "'mediaTypes' must not be null");
if (mediaTypes.size() > 1) {
mediaTypes.sort(SPECIFICITY_COMPARATOR);
} } public static void sortByQualityValue(List<MediaType> mediaTypes) {
Assert.notNull(mediaTypes, "'mediaTypes' must not be null");
if (mediaTypes.size() > 1) {
mediaTypes.sort(QUALITY_VALUE_COMPARATOR);
} } public static void sortBySpecificityAndQuality(List<MediaType> mediaTypes) {
Assert.notNull(mediaTypes, "'mediaTypes' must not be null");
if (mediaTypes.size() > 1) {
mediaTypes.sort(SPECIFICITY_COMPARATOR.thenComparing(QUALITY_VALUE_COMPARATOR));
} }
}
param 貌似都
RequestParam
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.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RequestParam {
@AliasFor("name")
String value() default ""; @AliasFor("value")
String name() default ""; boolean required() default true; String defaultValue() default "\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n";
}
@RequestMapping中的注解的更多相关文章
- SpringBoot中常用注解@Controller/@RestController/@RequestMapping的区别
@Controller 处理http请求 @Controller //@ResponseBody public class HelloController { @RequestMapping(valu ...
- SpringBoot 中常用注解@Controller/@RestController/@RequestMapping的区别
SpringBoot中常用注解@Controller/@RestController/@RequestMapping的区别 @Controller 处理http请求 @Controller //@Re ...
- SpringBoot 中常用注解@Controller/@RestController/@RequestMapping介绍
原文 SpringBoot 中常用注解 @Controller/@RestController/@RequestMapping介绍 @Controller 处理http请求 @Controller / ...
- spring注解开发中常用注解以及简单配置
一.spring注解开发中常用注解以及简单配置 1.为什么要用注解开发:spring的核心是Ioc容器和Aop,对于传统的Ioc编程来说我们需要在spring的配置文件中邪大量的bean来向sprin ...
- Spring MVC 中采用注解方式 Action中跳转到另一个Action的写法
Spring MVC 中采用注解方式 Action中跳转到另一个Action的写法 在Action中方法的返回值都是字符串行,一般情况是返回某个JSP,如: return "xx" ...
- SpringBoot 中常用注解
本篇博文将介绍几种SpringBoot 中常用注解 其中,各注解的作用为: @PathVaribale 获取url中的数据 @RequestParam 获取请求参数的值 @GetMapping 组合注 ...
- SSM-SpringMVC-14:SpringMVC中大话注解式开发基础--呕心沥血版
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 注解的基础我不再多啰嗦,百度一搜很多,很详细啊,我就讲一下SpringMVC中的注解入门 通过注解的方式定义 ...
- SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍
SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍 本篇博文将介绍几种如何处理url中的参数的注解@PathVaribale/@Requ ...
- Spring MVC 中 @ModelAttribute 注解的妙用
Spring MVC 中 @ModelAttribute 注解的妙用 Spring MVC 提供的这种基于注释的编程模型,极大的简化了 web 应用的开发.其中 @Controller 和 @Rest ...
随机推荐
- Linux下 导出postgrelSql 数据库
登陆postgrel su - postgres 进入postgrelsql 安装目录下的bin目录 cd/usr/pgsql-11/bin 执行导出命令 ./pg_dump -U username ...
- 导入一个eclipse的java项目到IDEA报Cannot find JDK '1.7' for module 'TEST'
解决办法: 右键你的项目--------------->OPen module settings 将dependencies里面的module sdk改成你安装的java版本就可以了(比如我电脑 ...
- LODOP打印项水平居中
LODOP控制打印项水平居中,可以用如下语句,该语句控制的是打印项本身在纸张中水平居中.LODOP.SET_PRINT_STYLEA(0,"Horient",2);这个根据大的打印 ...
- Navicat工具链接 mysql"Access denied for user'root'@'IP'" 用户远程赋值
如题 用Navicat远程连接数据库出现错误 给用户添加权限 连接MySQL mysql -uroot -p: use mysql; 更改权限 使用grant all privileges on来 ...
- python爬虫1
1 网页结构 html:超文本标记语言------->类似人的鼻子耳朵,长在那里,大体骨架就是那个样子 css:层叠样式表------->这个是外观的深化,比如贴个双眼皮,橙色眼睛... ...
- zookeeper学习整理
概述 zookeeper是一个高可用的分布式数据管理与协调框架,基于ZAB算法实现,主要解决分布式一致性问题. https://www.cnblogs.com/felixzh/p/5869212.ht ...
- java开发异常Exception集锦
背景:整理开发过程中的异常问题 java.lang.Exception: No tests found matching 一般出现在新导入的工程中.在sts中通过open project的方式导入工程 ...
- 通过python批量修改mp3名称
下载歌曲软件:音乐狂 下载格式:[xxxx]xxxx.mp3 import osimport re path = 'c:\\test' old_dir = os.listdir(path) print ...
- STL源码剖析——序列式容器#2 List
list就是链表的实现,链表是什么,我就不再解释了.list的好处就是每次插入或删除一个元素,都是常数的时空复杂度.但遍历或访问就需要O(n)的时间. List本身其实不难理解,难点在于某些功能函数的 ...
- gdocrimg04从库无法重启问题
1.查看error.logVersion: '5.6.25-log' socket: '/tmp/mysqld.3324_gdocrimg04.sock' port: 3324 Source d ...