@Slf4j
public class CommonTest {
@Test
public void test() throws Exception {
File file = new File("file");
String url = "http://xxx";
BufferedReader reader = null;
reader = new BufferedReader(new FileReader(file));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
RestTemplate restTemplate = new RestTemplate();
String tempString = null;
while ((tempString = reader.readLine()) != null) {
String phone = tempString.split(" ")[0];
String content = tempString.split(" ")[1];
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("phone","111");
map.add("content","1111");
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);
restTemplate.postForObject(url,request,String.class);
}
}
}
restTemplate 提交表单
最新推荐文章于 2023-12-25 11:36:24 发布