java - javax.ws.rs.Produces 在 Spring 中等效
问题描述
@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")
推荐阅读
- jenkins - dsl中的jenkins naginator插件
- ada - 相当于 Ada 中的访问器
- c# - 无法在 MAC OS 上安装 ML.NET(项目不支持 DotnetTool)
- javascript - Firebase 存储 getDownloadUrl 不是函数
- sql-server - 将共享数据集参数传递给表达式?
- postgresql - 如何在 Postgres 和 Apache Superset 中使用公元前 80 万年
- video - Xamarin 表单:用于播放视频的 Webview 在 iPhone 中不起作用?
- css - 为什么我的两个菜单“Font Awesome”图标突然显示为正方形?
- python - 如何从python中的csv文件中动态选择一行
- c# - .Net Core 3 和 Blazor 的 C# Selenium 测试用例可靠性