RESTTemplate参数未收到String

时间:2017-09-19 17:53:08

标签: resttemplate

我有以下REST API:

@RequestMapping(value = "saveSetting", method = RequestMethod.POST)
public @ResponseBody Boolean saveSetting(@RequestBody String settingXML) {

    //logs debug message
    logger.debug("saveSetting is executed!");

    Boolean success = false;

    System.out.println("xmlstring is " + settingXML);

    try {
        config.setSettings(null);
        success = Setting.saveSetting(settingXML, "C:\\Users\\hansa\\ConfigSetting.xml");
    } catch (Exception e) {
        e.printStackTrace();
    }

    logger.debug("saveSetting is returned");

    return success;
}

我的RESTTemplate代码如下:

RestTemplate restTemplate = new RestTemplate();

    MultiValueMap<String, String> parametersMap = new LinkedMultiValueMap<String, String>();
    parametersMap.add("settingXML", stringXML);



    Boolean success = restTemplate.postForObject(serverURL, parametersMap, Boolean.class);

调用API并获得响应,没有异常。但是,我作为参数发送的字符串是空字符串。知道我在通过电话发送字符串时做错了吗?

0 个答案:

没有答案