java mediatype utf-8_Java MediaType.APPLICATION_JSON_UTF8屬性代碼示例

java mediatype utf-8_Java MediaType.APPLICATION_JSON_UTF8屬性代碼示例/***Searches{@linkorg.springframework.web.bind.annotation.RequestMappingRequestMapping}*annotationonthegivenmethodargumentandextracts*IfRequestMappingannotationisnotfound,NoRequestM…

大家好,又见面了,我是你们的朋友全栈君。

/**

* Searches {@link org.springframework.web.bind.annotation.RequestMapping RequestMapping}

* annotation on the given method argument and extracts

* If RequestMapping annotation is not found, NoRequestMappingFoundException is thrown.

* {@link org.springframework.http.HttpMethod HttpMethod} type equivalent to

* {@link org.springframework.web.bind.annotation.RequestMethod RequestMethod} type

*

* @param element AnnotatedElement object to be examined.

* @return Mapping object

*/

Mapping extractMapping(AnnotatedElement element) {

Annotation annotation = findMappingAnnotation(element);

String[] urls;

RequestMethod requestMethod;

String consumes;

if (annotation instanceof RequestMapping) {

RequestMapping requestMapping = (RequestMapping) annotation;

requestMethod = requestMapping.method().length == 0

? RequestMethod.GET : requestMapping.method()[0];

urls = requestMapping.value();

consumes = StringHelper.getFirstOrEmpty(requestMapping.consumes());

} else if (annotation instanceof GetMapping) {

requestMethod = RequestMethod.GET;

urls = ((GetMapping) annotation).value();

consumes = StringHelper.getFirstOrEmpty(((GetMapping) annotation).consumes());

} else if (annotation instanceof PostMapping) {

requestMethod = RequestMethod.POST;

urls = ((PostMapping) annotation).value();

consumes = StringHelper.getFirstOrEmpty(((PostMapping) annotation).consumes());

} else if (annotation instanceof PutMapping) {

requestMethod = RequestMethod.PUT;

urls = ((PutMapping) annotation).value();

consumes = StringHelper.getFirstOrEmpty(((PutMapping) annotation).consumes());

} else if (annotation instanceof DeleteMapping) {

requestMethod = RequestMethod.DELETE;

urls = ((DeleteMapping) annotation).value();

consumes = StringHelper.getFirstOrEmpty(((DeleteMapping) annotation).consumes());

} else if (annotation instanceof PatchMapping) {

requestMethod = RequestMethod.PATCH;

urls = ((PatchMapping) annotation).value();

consumes = StringHelper.getFirstOrEmpty(((PatchMapping) annotation).consumes());

} else {

throw new NoRequestMappingFoundException(element);

}

HttpMethod httpMethod = HttpMethod.resolve(requestMethod.name());

String url = StringHelper.getFirstOrEmpty(urls);

MediaType mediaType;

try {

mediaType = MediaType.valueOf(consumes);

} catch (InvalidMediaTypeException exception) {

mediaType = MediaType.APPLICATION_JSON_UTF8;

}

return new Mapping(httpMethod, url, mediaType);

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/144984.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • USB转RS485/RS422接线说明

    USB转RS485/RS422接线说明       

    2022年6月6日
    82
  • JMM 详解_jmm是什么意思

    JMM 详解_jmm是什么意思多任务和高并发的内存交互多任务和高并发是衡量一台计算机处理器的能力重要指标之一。一般衡量一个服务器性能的高低好坏,使用每秒事务处理数(TransactionsPerSecond,TPS)这个指标比较能说明问题,它代表着一秒内服务器平均能响应的请求数,而TPS值与程序的并发能力有着非常密切的关系。物理机的并发问题与虚拟机中的情况有很多相似之处,物理机对并发的处理方案对于虚拟机的实现也有相

    2025年9月14日
    8
  • rime android汉字,Rime输入法

    rime android汉字,Rime输入法Rime输入法的安卓版又叫同文输入法,是Rime输入法好几个版本中的一个,适合喜欢调校的人。界面比较简洁,也很小巧,功能就是输入,偏英文输入,支持调整颜色更改外观。Rime输入法简介RIME/中州韻輸入法引擎,是一個跨平臺的輸入法算法框架。基於這一框架,Rime開發者與其他開源社區的參與者在Windows、MacOSX、Linux、Android平臺上創造了不同的輸入法前端實現。Rime…

    2022年7月12日
    33
  • 将整型变量转化为字符串_字符转字符串

    将整型变量转化为字符串_字符转字符串strsep(&data,”,”); //字符串切割函数kstrtoint(first,10,&duty_cycle);//字符串转整形10:十进制sprintf(data,”%d,%d”,duty_cycle,fan_freq);//整型数转字符串示例代码:ssize_tdcfan_write(structfile*file,constchar__user…

    2022年10月18日
    6
  • android双缓冲技术,Android VSYNC与图形系统中的撕裂、双缓冲、三缓冲浅析

    android双缓冲技术,Android VSYNC与图形系统中的撕裂、双缓冲、三缓冲浅析先接触两个图形概念:帧率(FrameRate,单位FPS)–GPU显卡生成帧的速率,也可以认为是数据处理的速度),屏幕刷新频率(RefreshRate单位赫兹/HZ):是指硬件设备刷新屏幕的频率。屏幕刷新率一般是固定的,比如60Hz的每16ms就刷一次屏幕,可以类比一下黑白电视的电子扫描枪,每16ms电子枪从上到下从左到右一行一行逐渐把图片绘制出来,如果GPU显卡性能非常强悍,帧率可以…

    2022年5月11日
    49
  • 字符串数组转换为list集合

    字符串数组转换为list集合String[]arr={“a”,”C”,”abc”}; //asList该方法可以直接将一个数组转换为list集合,但是该集合是[只读的],不能对得到的集合进行增删改List<String>asList=Arrays.asList(arr);System.out.println(asList);//结果:[a,C,abc]Listlis…

    2022年6月21日
    35

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号