@Test
    public void webTest() throws JsonProcessingException {

        Map<String, String> a = new HashMap<>();

        a.put("userName", "ff");
        a.put("password", "fff");

        ObjectMapper b = new ObjectMapper();

        String as = b.writeValueAsString(a);

        HttpHeaders headers2 = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers2.setContentType(type);
        headers2.add("Accept", MediaType.APPLICATION_JSON.toString());

        HttpEntity<String> entity = new HttpEntity<String>(as, headers2);

        Object ss = restTemplate.postForObject("http://localhost:" + port + "/api/admin/login2", entity, Object.class);
        System.out.println("port is: " + port);
    }

 

posted on 2019-03-30 07:38  wblade  阅读(154)  评论(0编辑  收藏  举报