[英]Jersey throws Bad request exception(400)
While trying to get single record from database jersey throws Bad request exception.Kindly somebody help me to fix that. 尝试从数据库jersey获取单个记录时抛出Bad Request异常。请帮助我解决此问题。
Ajax :- 阿贾克斯:-
var id = $(this).attr("data-id").trim();
$.ajax({
url:"./scalegdn/service/getServiceById/"+id,
method:"get",
dataType:"json",
success:function(data){
$("#servicename").val(data.serviceName);
$("#description").val(data.serviceDescription);
}
});
Jersey resource :- 泽西岛资源:-
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/getServiceById/{id}")
public ServiceTO getServiceById(@PathParam("id") int id) throws Exception {
ServiceDAO servicedao = null;
ServiceTO service=null;
logger.info("id is:"+id);
try {
service=servicedao.getServiceById(id);
} catch (Exception e) {
logger.error("Error occurs,While trying to get service by serviceId.",e);
} finally {
if (!connection.isClosed()) {
connection.close();
}
}
return service;
}
check @PathParam package your imported. 检查@PathParam打包导入。 try to use jersey dependency.
尝试使用球衣依赖。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.