我有一个AngularJS web应用程序调用我自己的Java Jersey API。现在一切都在localhost上运行。POST 500(内部服务器错误) - AngularJS - Jersey API
这是角电话:
function Create(user) {
return $http.post('http://localhost:8080/NobelGrid/api/users/create/', user).then(handleSuccess, handleError('Error creating user'));
}
这是REST的我的代码片段:
@Path("/create")
@POST
@Produces("application/json")
public Response create(String data) {
UserDataConnector connector;
JSONObject response = new JSONObject(data);
User userToCreate = new User(response.getString("surname"), response.getString("name"),
response.getString("mail"), response.getString("username"), response.getString("password"), 0);
try {
connector = new UserDataConnector();
connector.createUser(userToCreate);
} catch (IOException e) {
e.printStackTrace();
}
return Response.status(Response.Status.OK) // 200
.entity(userToCreate)
.build();
}
我简单地插入我自己的MySQL数据库的用户。
程序进行得很顺利导致用户被添加到Db中,无论如何它返回给我那个错误。
请谁能帮助我?
500表示请求处理期间服务器端出现问题。所以添加你的服务器错误日志。 – mmuzahid
@mmuzahid我知道这一点。但正如我所说,在服务器端看起来一切都很顺利:用户被添加到BD。我在调试模式下通过指令执行所有的服务和指令,并且没有发生异常。 –
为什么额外的'/'在URL中的'/ create'后面?我认为它应该是:'http:// localhost:8080/NobelGrid/api/users/create' –