即使请求将内容类型设置为text / plain,Spring 5也会将内容作为application / json返回

时间:2018-08-09 10:08:33

标签: java spring spring-mvc

我已经从Spring 3升级到Spring 5.0.5。当我尝试获取使用@ResponseBody注释的资源并且未提供“ produces”变量中的内容类型时,我总是以application / json的形式接收内容。虽然在请求中我将Accept标头传递为text / plain

@RequestMapping(value = "/{id}/script", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@PublicAPI
@ResponseBody
@DocAuthResource(category = "enclosure-groups", action = Action.READ, scopedBy = Property.NONE)
public String getConfigScript(
        final HttpServletRequest request,
        final HttpServletResponse response,
        @PathVariable final String id,
        @RequestHeader final String auth,
        @RequestHeader(required = false, value = "accept-language") final String locale)
        throws CiException
{
    return encGroupService.getConfigScript(id);
}

您能否让我知道如何根据请求中提供的Accept标头接收响应?

0 个答案:

没有答案