RSA+AES实现接口验签和参数加密( 六 )

需要传递的业务参数对象@Datapublic class RequestDto {private String name;private int age;private String hobby;}发送请求 public static void main(String[] args) {//请求地址String url = "http://127.0.0.1:8888/test";RequestDto requestDto = new RequestDto();requestDto.setAge(100);requestDto.setName("Longer");requestDto.setHobby("ball");String json = JacksonUtil.beanToJson(requestDto);//appIdString appId = "";//rsa公钥String publicKey = "";//rsa私钥String privateKey = "";HttpClientUtils.doPostJsonForSign(url, json, appId, publicKey, privateKey)}接收方controller@Slf4j@RestControllerpublic class TestController {@RequestMapping("test")public String test(RequestDto requestDto){log.info("接收到的请求参数为:"+ JacksonUtil.beanToJson(requestDto));return "a";}}因为我们对参数进行了统一处理,所以我们的controller接收参数的对象是RequestDto对象,而不是JsonRequest对象

原文链接:
https://www.jianshu.com/p/9061da5e25d1

【RSA+AES实现接口验签和参数加密】


推荐阅读