服务调用端代码
String forObject = restTemplate.postForObject(HotelService + "/http://localhost:7004/bookRoom/" + hoteltype + "/" + amount + "/" + period, period, String.class);
period是一个实体类,要使用 postForObject方法,我刚开始使用的是getForObject,就报了500的错误.
服务端的Controller,period记得使用@RequestBody
```java
@RequestMapping("/bookRoom/{type}/{amount}/{period}")
public String bookRoom(@PathVariable("type") String type, @PathVariable("amount") int amount, @RequestBody StayPeriod period) throws IOException, DocumentException {
System.out.println("Controller--period :"+period);
String s = hotelReservationWS.bookRoom(type, amount,period);
return s;
}