Skip to content

Instantly share code, notes, and snippets.

@adityasatrio
Created February 25, 2015 05:58
Show Gist options
  • Save adityasatrio/cf6b9986747d0e99bf02 to your computer and use it in GitHub Desktop.
Save adityasatrio/cf6b9986747d0e99bf02 to your computer and use it in GitHub Desktop.
Post Rest using spring mvc - restTemplate
pom.xml :
<spring-framework.version>4.1.1.RELEASE</spring-framework.version>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-framework.version}</version>
</dependency>
implementation :
public static final String REST_SERVER = "http://localhost:8080/MIA-WS";
public static final String GET_TOTAL_SHIPMENT_AND_PIECES = "/rest/total/shipment/pieces";
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("paramater","parameter");
RestTemplate restTemplate = new RestTemplate();
String urlRest = Constants.REST_SERVER + Constants.GET_TOTAL_SHIPMENT_AND_PIECES;
List<Object> returnValue = restTemplate.postForObject(urlRest, paramMap, List.class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment