【发布时间】:2018-12-15 12:25:38
【问题描述】:
获取 Spring Rest 控制器 Web 服务的以下异常:-
org.springframework.web.client.HttpClientErrorException: 415 不支持的媒体类型 在 org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) 在 org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:667)
代码:
public class PaymentProcessController {
@RequestMapping(value = "/payment_failure", method = RequestMethod.POST)
public ModelAndView savePayFailure(HttpServletRequest request, HttpServletResponse response, HttpSession session)
{
RestTemplate restTemplate = new RestTemplate();
Invoice invoice = restTemplate.getForObject(
"http://localhost:8080/rooftop/invoice/findByProperty/TRANASACTION_NO/" + tx
nid, Invoice.class);
}
REST 客户端在 InvoiceRestController 中编写如下:
InvoiceRestController:
@RestController @RequestMapping(value = "/invoice/")
public class
InvoiceRestController { @RequestMapping(value =
"/findByProperty/{property}/{value}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE, consumes =
MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Invoice> findByProperty(@PathVariable String property, @PathVariable String value) throws Exception {
}
【问题讨论】:
-
请提出解决方案
-
您使用什么客户端来调用
savePayFailureakapayment_failure映射? -
payment_failure 是客户端,是 Spring mvc 前端控制器