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)
上一篇 2022年5月12日 下午7:20
下一篇 2022年5月12日 下午7:20


相关推荐

  • keras多层感知器识别手写数字执行预测代码_感知机模型多层神经网络

    keras多层感知器识别手写数字执行预测代码_感知机模型多层神经网络2.Keras建立多层感知器模型2.1简单介绍多层感知器模型注:以下模型及其说明来自于《TensorFlow+Keras深度学习人工智能实践应用》林大贵著以矩阵方式仿真多层感知器模型的工作方式(如下图所示)建立输入与隐藏层的公式:h1=ReLu(x*w1+b1)变量名说明输入层x仿真输入神经元接收外界传送消息,如上图所示,共有784个神经元。隐藏层h1…

    2022年10月9日
    5
  • UML——交互图

    UML——交互图UML——交互图

    2022年4月24日
    69
  • 使用javascript实现数组截取

    使用javascript实现数组截取前言:在开发项目的过程中遇到这样的一个问题,就是需要对接口查询出来的数据两个两个的进行截取,之后分别两个两个的放入数组中,再把这些数组放到一个新数组中,实现方法如下:方法一:functionarrayChunk(array,size){ letdata=[]; for(leti=0;i<array.length;i+=size){ data.push(array.slice(i,i+size)) } returndata;}arrayChunk([{i

    2022年6月5日
    41
  • C语言多线程编程一

    C语言多线程编程一C 语言多线程编程一 c 语言中有一个函数可以实现简单的多线程编程 它的函数原型为 uintptr t beginthread void start address void unsignedstac size void arglist Parameters 参数 start address 程序执行一个新线程的起始地址 即你写的执行函数名 Startaddress

    2026年3月26日
    2
  • 张予彤出任月之暗面总裁,负责公司整体战略与商业化

    张予彤出任月之暗面总裁,负责公司整体战略与商业化

    2026年3月12日
    3
  • python中如何打开csv文件_python如何读取csv文件

    python中如何打开csv文件_python如何读取csv文件python如何读取csv文件,我们这里需要用到python自带的csv模块,有了这个模块读取数据就变得非常容易了。工具/原料python3方法/步骤1这里以sublimetext3编辑器作为示范,新建一个文档。2我们可以先确认CSV文档是否可以正确打开。并且放在同一个文件夹里面。3importcsv这是第一步要做的,就是调用csv模块。4importcsvfile=open(‘data…

    2022年7月21日
    31

发表回复

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

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