[英]500 (Internal Server Error) when send json to restful web services java
I am working on a web service to insert data into a sqd server, as I am new to this, I am doing small tests. 我正在研究一种将数据插入到sqd服务器中的Web服务,这是我的新手,因此我正在做一些小测试。
You have created a rest web service in netbeans, create a person entity, the only thing that the service does is receive an object in xml or json format and then store it in persistence. 您已经在netbeans中创建了一个rest Web服务,创建了一个person实体,该服务唯一要做的就是接收xml或json格式的对象,然后将其存储为持久性。 When I send an xml format like this: 当我发送这样的xml格式时:
<persona>
<idPersona>20</idPersona>
<nombre>Albert</nombre>
<trabajador>true</trabajador>
</persona>"
Works fine, but when I send the object in json format like this: 工作正常,但是当我以json格式发送对象时,如下所示:
{
"idPersona":"20",
"nombre":"Bernard",
"trabajador":"true"
}
I get a 500 (Internal Server Error). 我得到500(内部服务器错误)。 I have been guiding a tutorial online, I followed all the steps, in the tutorial there are pictures and everything is perfect, but in my case it is not like that. 我一直在网上指导一个教程,我按照所有步骤进行操作,该教程中有图片,并且一切都很完美,但就我而言,事实并非如此。
Did someone have the same problem? 有人有同样的问题吗? I hope you can help me. 我希望你能帮助我。 Thank you. 谢谢。
You treat your boolean like a string and persona is missing. 您将布尔值视为字符串,并且缺少角色。 But your json should look like this: 但是您的json应该看起来像这样:
{
"persona": {
"idPersona": "20",
"nombre": "Bernard",
"trabajador": true
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.