包@Produces(javax.ws.rs.core. MediaType.APPLICATION_JSON)
中是否有与org.springframework.web.bind.annotation
等效的注释,以免两者混用?我现在正在做...
@PostMapping("/price-menu")
@Produces(javax.ws.rs.core. MediaType.APPLICATION_JSON)
public ResponseEntity<Currency> menus
(HttpServletRequest request) {
..
}
最佳答案
@PostMapping有一个名为produces
的参数。 (https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/annotation/PostMapping.html#produces--)
您可以像这样使用它:@PostMapping(path = "/price-menu", consumes = "application/json", produces = "application/json")