• 大小: 52KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: Java
  • 标签: SpringBoot  okhttp3  

资源简介

SpringBoot OkHttp3,里面包含了各种测试代码,其中包含了get,post,文件上传等测试

资源截图

代码片段和文件信息

package cn.ok.http.controller;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import cn.ok.http.utils.FileUtil;

@RestController
@RequestMapping(“/okHttp“)
public class OkHttpController {

    @RequestMapping(value = “/request“ method = { RequestMethod.GET RequestMethod.POST })
    public String request() {
        return “index/index“;
    }

    @RequestMapping(value = “requestWithHeaders“method = { RequestMethod.GET RequestMethod.POST } )
    String requestWithHeaders(@RequestHeader(value = “authorization_token“ required = true) String token
                      @RequestHeader(value = “mac_address“ required = true) String macAddress) {

        return  String.format(“authorization_token is %s mac_address is %s“ token macAddress);
    }

    @RequestMapping(value = “/requestWithParams“method = { RequestMethod.GETRequestMethod.POST } )
    String requestWithParams(@RequestParam(value = “userName“ required = true)  String paramNameUser
                         @RequestParam(value = “userAge“  required = true) int paramAge) {
        return  String.format(“paramNameUser is %s paramAge is %s“ paramNameUser paramAge);
    }

    @RequestMapping(value = “/requestWithHeadersAndParams“method = { RequestMethod.GETRequestMethod.POST } )
    String requestWithHeadersAndParams( @RequestParam(value = “userName“ required = true)  String paramNameUser
                                @RequestParam(value = “userAge“  required = true) int paramAge
                                @RequestHeader(value = “authorization_token“ required = true) String token
                                @RequestHeader(value = “mac_address“ required = true) String macAddress
                                ) {

        return  String.format(“paramNameUser is %s paramAge is %sauthorization_token is %smac_address is %s“ paramNameUser paramAgetokenmacAddress);
    }

    @RequestMapping(value = “/queryByByJson“method = { RequestMethod.POST } )
    public object queryByTipper(@RequestBody Map request) {
        return  request;
    }


    @RequestMapping(value = “/sessionLogin“ method = RequestMethod.POST)
    public object sessionLogin (String userNameString  passWord HttpServletRequest request){
        Map user = new HashMap();
        user.put(“userName“userNa

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        624  2019-02-21 14:34  okHttp\.idea\compiler.xml

     文件        172  2019-02-21 14:34  okHttp\.idea\encodings.xml

     文件        568  2019-02-21 14:34  okHttp\.idea\libraries\Maven__ch_qos_logback_logback_classic_1_1_9.xml

     文件        547  2019-02-21 14:34  okHttp\.idea\libraries\Maven__ch_qos_logback_logback_core_1_1_9.xml

     文件        525  2019-02-21 14:40  okHttp\.idea\libraries\Maven__commons_lang_commons_lang_2_6.xml

     文件        507  2019-02-21 14:34  okHttp\.idea\libraries\Maven__com_alibaba_fastjson_1_2_4.xml

     文件        522  2019-02-21 14:34  okHttp\.idea\libraries\Maven__com_fasterxml_classmate_1_3_3.xml

     文件        644  2019-02-21 14:34  okHttp\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_0.xml

     文件        595  2019-02-21 14:34  okHttp\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_core_2_8_6.xml

     文件        623  2019-02-21 14:34  okHttp\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_databind_2_8_6.xml

     文件        499  2019-02-21 14:34  okHttp\.idea\libraries\Maven__com_google_guava_guava_18_0.xml

     文件        546  2019-02-21 14:34  okHttp\.idea\libraries\Maven__com_jayway_jsonpath_json_path_2_2_0.xml

     文件        536  2019-02-21 14:34  okHttp\.idea\libraries\Maven__com_squareup_okhttp3_okhttp_3_13_1.xml

     文件        510  2019-02-21 14:34  okHttp\.idea\libraries\Maven__com_squareup_okio_okio_1_17_2.xml

     文件        700  2019-02-21 14:34  okHttp\.idea\libraries\Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml

     文件        553  2019-02-21 14:34  okHttp\.idea\libraries\Maven__io_springfox_springfox_core_2_6_1.xml

     文件        567  2019-02-21 14:34  okHttp\.idea\libraries\Maven__io_springfox_springfox_schema_2_6_1.xml

     文件        546  2019-02-21 14:34  okHttp\.idea\libraries\Maven__io_springfox_springfox_spi_2_6_1.xml

     文件        595  2019-02-21 14:34  okHttp\.idea\libraries\Maven__io_springfox_springfox_spring_web_2_6_1.xml

     文件        581  2019-02-21 14:34  okHttp\.idea\libraries\Maven__io_springfox_springfox_swagger2_2_6_1.xml

     文件        623  2019-02-21 14:34  okHttp\.idea\libraries\Maven__io_springfox_springfox_swagger_common_2_6_1.xml

     文件        595  2019-02-21 14:34  okHttp\.idea\libraries\Maven__io_springfox_springfox_swagger_ui_2_6_1.xml

     文件        587  2019-02-21 14:34  okHttp\.idea\libraries\Maven__io_swagger_swagger_annotations_1_5_10.xml

     文件        552  2019-02-21 14:34  okHttp\.idea\libraries\Maven__io_swagger_swagger_models_1_5_10.xml

     文件        578  2019-02-21 14:34  okHttp\.idea\libraries\Maven__javax_servlet_javax_servlet_api_3_1_0.xml

     文件        473  2019-02-21 14:34  okHttp\.idea\libraries\Maven__javax_servlet_jstl_1_2.xml

     文件        611  2019-02-21 14:34  okHttp\.idea\libraries\Maven__javax_validation_validation_api_1_1_0_Final.xml

     文件        455  2019-02-21 14:34  okHttp\.idea\libraries\Maven__junit_junit_4_12.xml

     文件        542  2019-02-21 14:34  okHttp\.idea\libraries\Maven__net_minidev_accessors_smart_1_1.xml

     文件        521  2019-02-21 14:34  okHttp\.idea\libraries\Maven__net_minidev_json_smart_2_2_1.xml

............此处省略91个文件信息

评论

共有 条评论