- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
使用Postman测试REST Controller (使用SpringBoot开发)时,反复获取415状态码。
仅在特定帖子请求时发生。其他帖子请求工作正常。模仿了工作岗位 Controller ,但没有成功。
@RequestMapping(value="/addtheatre", method= RequestMethod.POST)
public HttpStatus addTheatre(@RequestBody Theatre theatre ) {
theatrerepository.save(theatre);
return HttpStatus.OK;
}
剧院实体如下:-包 com.example.Model;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.stereotype.Component;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.sql.Time;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@Entity(name="Theatre")
public class Theatre {
Theatre()
{}
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name="Id")
private long id;
@Column(name="name")
@NotNull
private String name;
@Column(name="address")
@NotNull
private String address;
@Column(name="city")
@NotNull
private String city;
@Column(name="is_active")
@NotNull
private Boolean is_active;
@Transient
private List<TheatreHall> halls;
@Transient
private Map <Movie,LinkedList<Time>> map;
public Boolean getIs_active() {
return is_active;
}
public void setIs_active(Boolean is_active) {
this.is_active = is_active;
}
public List<TheatreHall> getHalls() {
return halls;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setHalls(List<TheatreHall> halls) {
this.halls = halls;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public Map<Movie, LinkedList<Time>> getMap() {
return map;
}
public void setMap(Map<Movie, LinkedList<Time>> map) {
this.map = map;
}
@Override
public String toString() {
return "Theatre{" +
"id=" + id +
", name='" + name + '\'' +
", address='" + address + '\'' +
", city='" + city + '\'' +
", is_active=" + is_active +
", halls=" + halls +
", map=" + map +
'}';
}
}
Postman测试数据如下:-
端点:-localhost:8080/addtheatre
请求:-
{
"name":"PVR Mall",
"address":"Andheri",
"city":"Mumbai",
"is_active":"true"
}
回应:-
{
"timestamp": "2018-12-26T08:21:43.269+0000",
"status": 415,
"error": "Unsupported Media Type",
"message": "Content type 'application/json;charset=UTF-8' not supported",
"path": "/addtheatre"
}
预计此 POST Controller 状态正常。
最佳答案
将 is_active 更改为 isActive,将 setter 更改为 setIsActive。我怀疑 Jackson 由于命名约定而无法找到 is_active 的相关 setter,因此无法解析该对象
关于java - 使用消息 "message": "Content type ' text/plain;charset=UTF- 8' not supported" 测试 Post API 时获取 415 状态代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53929483/
所以,据我所知,这个类并不存在于标准 Java 库中,而是 Dalvik 中的新增内容。这是正确的吗? 我认为这是 android 类“NdefRecord”包含对它的引用并使用它的原因,但无法将其导
我想创建一些处理编码的示例程序,特别是我想使用宽字符串,例如: wstring a=L"grüßen"; wstring b=L"שלום עולם!"; wstring c=L"中文"; 因为这些是
有人知道一种更快的方法来完成 java.nio.charset.Charset.decode(..)/encode(..) 的功能吗? 这是我目前使用的技术的瓶颈之一。 [编辑]具体来说,在我的应用程
我想创建一些处理编码的示例程序,特别是我想使用宽字符串,例如: wstring a=L"grüßen"; wstring b=L"שלום עולם!"; wstring c=L"中文"; 因为这些是
我正在检查代码并遇到以下行。 Charset.forName("ASCII") 但是当我查看 java documentation它只有 US-ASCII ISO-8859-1 UTF-8
初始化 PDO 时 - 我应该做:charset=UTF8 还是 charset=UTF8MB4? 这是我的初始化: $dsn = 'mysql:host=example.com;dbname=tes
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
据我所知,在 String.getBytes(charset) 中,参数 charset 表示该方法返回编码为给定字符集的字符串字节。 在 new String(bytes, charset) 中,第
我正在使用 sqlsrv 驱动程序连接到带有 PDO 的 MS SQL 服务器。 PHP 版本为 5.3.24。工作连接如下所示: $dsny = "sqlsrv:Server=xx1;Databas
我的算法有两个输入: 1 个将被编码的 utf8 String 对象 1 个字符集对象,指示我需要将字符串编码成什么 最后,返回的结果将被放入一个OutputStream,一个可能发生多次但至少一次的
获取多个字符集:text/json; Charset=UTF-8;charset=utf-8 OkHttp Header 调用 okHttp Library 服务器时。有人知道我该如何解决这个问题。
使用 firebug 时,我在我的 asp.net mvc 4 项目中收到此连线错误“NetworkError: 415 Cannot process the ...xt/xml; charset=u
当我尝试通过 ant 运行我的 TestNG 测试时,我得到了 java.lang.NoSuchMethodError: org.springframework.http.MediaType.getC
我正在使用 .NET 4.0 在 IIS 7.5 中托管 WCF 服务。我还有一个 WPF 应用程序,用作我的客户端,它是使用 Visual Studio 2010 和 .NET 4.0 构建的。我添
我一直在尝试向 soap 服务器发送正确的请求。我不断收到错误消息。 这是我的xml GET LAST REQUEST(添加换行符): 1 获取最后的回复: 请求 header : POST /
我在通过 ajax json 调用 WCF 服务时收到上述响应。我的调用代码是: $(document).ready(function () { $.ajax
我尝试使用独立应用程序使用 WCF Web 服务。我可以使用 Internet Explorer 查看此服务,也可以在 Visual Studio 服务引用中查看。 这是我遇到的错误 The cont
我使用独立应用程序创建了 WCF 服务并测试了 WCF 客户端。我能够使用 Internet Explorer 查看此服务,也能够在 Visual Studio 服务引用中查看。这是错误消息。 “响应
我们有一个在 HTTPS 上运行良好但在 HTTPS 上显示 HTTP 415 错误的网络服务。因此,在 HTTP 下,我们可以毫无问题地发送和接收 JSON 的 POST 请求。当我们在 HTTPS
我正在将 spring-boot 从 1.3.6 更新到 2.1.3,而之前响应的内容类型为 application/json;charset=UTF-8 ,现在我得到了一个 iso-8859-1 的
我是一名优秀的程序员,十分优秀!