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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • OpenCv相机标定——圆形标定板标定[通俗易懂]

    OpenCv相机标定——圆形标定板标定[通俗易懂]Opencv相机标定之圆形标定板标定——本文主要介绍了OpenCv中圆形标定板的标定,并将标定结果与Halcon标定进行比较分析,得出OpenCv标定算法对图像品质的鲁棒性较高,标定精度较高。同时也从侧面反映出使用Halcon进行高精度标定时,对图像品质的要求较高,当然这也是高精度标定下的高要求。

    2022年5月27日
    46
  • 在pycharm中安装opencv_pycharm opencv

    在pycharm中安装opencv_pycharm opencv打开pycharm下方的terminal终端在路径下直接输入pipinstallopencv-python稍等片刻既安装成功在这里查看项目安装的模块点击左上方文件-设置-项目-Protect-Interpreter看到我们已经安装了opencv-python与numpy模块…

    2022年8月27日
    5
  • FileSystemWatcher 类

    FileSystemWatcher 类命名空间:System.IO程序集:System.IO.FileSystem.Watcher.dll,System.dll,netstandard.dll侦听文件系统更改通知,并在目录或目录中的文件发生更改时引发事件。Listenstothefilesystemchangenotificationsandraiseseventswhenadirector…

    2022年6月25日
    36
  • 四位数除以两位数的除法算式_4整除2

    四位数除以两位数的除法算式_4整除2原题链接这里所谓的“光棍”,并不是指单身汪啦~ 说的是全部由1组成的数字,比如1、11、111、1111等。传说任何一个光棍都能被一个不以5结尾的奇数整除。比如,111111就可以被13整除。 现在,你的程序要读入一个整数x,这个整数一定是奇数并且不以5结尾。然后,经过计算,输出两个数字:第一个数字s,表示x乘以s是一个光棍,第二个数字n是这个光棍的位数。这样的解当然不是唯一的,题目要求你输出最小的解。提示:一个显然的办法是逐渐增加光棍的位数,直到可以整除x为止。但难点在于,s可能是个非常大的数 ——

    2022年8月8日
    13
  • Android中定时器的使用

    Android中定时器的使用1.创建Timer对象,定时器本体。TimermTimer=newTimer();2.创建TimerTask对象,定义业务逻辑,TimerTask为接口,需要实现类,本文使用匿名内部类实现

    2022年7月1日
    24
  • 使用Proxmox搭建私有云平台

    使用Proxmox搭建私有云平台企业目前上云,有多种选择,那么对于中小企业,从成本和规模考虑,如何搭建自己的私有云环境,笔者这里根据自己的一个实践环境,尝试搭建一套小型私有云环境,功能并不完善,但基本能满足中小企业的需求。硬件环境准备环境的搭建,硬件成本是必须的,没有物理设备,那么巧妇难为无米之炊~~服务器设备:建议采购3台以上X86两路服务器,CPU配置根据需求,建议5218金牌。内存配置256G以上。配置SSD卡(3…

    2022年6月19日
    67

发表回复

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

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