尝试从数据库jersey获取单个记录时会抛出Bad request exception.Kindly有人帮我解决了这个问题。
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);
}
});
泽西岛资源: -
@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;
}
答案 0 :(得分:1)
检查导入的@PathParam包。尝试使用泽西依赖。