Spring RestTemplate get方式发送数据服务器端拿到为空
来源:互联网 发布:java 解决高并发 编辑:程序博客网 时间:2024/06/06 01:04
在使用Spring restTemplate类测试url接口的时候,使用get请求发送参数服务器端拿不到请求数据。
请求代码是这样的
Map<String, String> map = new HashMap<>(); map.put("p1", "myValue"); String url = "http://localhost:8080/sayHello"; String paramedUrl = "http://localhost:8080/sayHello?p1={p1}"; System.out.println(restTemplate.getForObject(paramedUrl, String.class, map));
url应该是要写成 paramedUrl 的形式,不是上面url的形式。类似于一个展位符的作用。
@RequestMapping("sayHello") @ResponseBody public String sayHello(HttpServletRequest httpServletRequest) { System.out.println("服务端拿到的是:" + httpServletRequest.getParameter("p1")); return "helloworld"; }
使用url的变量服务端拿到的是空,而使用paramedUrl 变量服务端可以正常拿到值
阅读全文
0 0
- Spring RestTemplate get方式发送数据服务器端拿到为空
- RestTemplate 发送 get 请求使用误区 多值为null
- RestTemplate 发送 get 请求使用误区 多值为null
- spring boot RestTemplate 发送 get 请求使用误区
- 用GET方式发送数据
- HttpWebRequest GET 方式发送数据
- Android GET,POST向服务器端发送数据(发送)
- Android GET,POST向服务器端发送数据(发送)
- django get 数据为空处理
- Spring通过RestTemplate传送数据
- ASIHTTPRequest 网络发送数据为空
- 解决RabbitMQ发送数据为空字符串
- post和get方式发送数据
- http 发送数据方式 post get soap
- AJAX发送数据之get请求方式
- Spring框架中发送http请求--RestTemplate
- Spring RestTemplate使用ByteArrayResource上传方式
- Spring RestTemplate中几种常见的请求方式
- matlab 二分法
- 枚举的定义和使用
- ts、js自定义方法,实现延迟
- flex布局1
- int (*p)[10] 和 int *p[10]的区别
- Spring RestTemplate get方式发送数据服务器端拿到为空
- IOS第三方库GPUImage添加到Xcode工程
- 58. Length of Last Word
- CodeChef Graphcnt:Counting on a directed graph(支配树)
- 视图观察者
- JS笔记 —— JS正则表达式大全
- LaTeX技巧一:如何在标题页面上创建背景图像?
- 使用原生js替换jQuery
- 深入理解c++笔记