无法通过QueryParamqq从JSON获取id

时间:2016-10-11 04:52:42

标签: java json database

我希望从2表中得到2个id(id和manufacturer_id),如下所示: 没问题,但如果我改变id=661的参数。网址:http://localhost:9999/TestJersey/rest/test/getID?id=661&manufacturer_id=1

它似乎发生错误,我无法从数据库中获取任何数据。 这是我的班级:

这是我的POJO

public class DetailManufacturer {

private Integer id; 
private String name;
private String price;
private Integer manufacturer_id;
private String manufacturer_name;

public DetailManufacturer() {

}

public DetailManufacturer(Integer id, String name, String price, Integer manufacturer_id, String manufacturer_name) {
    this.id = id;
    this.name = name;
    this.price = price;
    this.manufacturer_id = manufacturer_id;
    this.manufacturer_name = manufacturer_name;
}
public Integer getId() {
    return id;
}
public void setId(Integer id) {
    this.id = id;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public String getPrice() {
    return price;
}
public void setPrice(String price) {
    this.price = price;
}
public Integer getManufacturer_id() {
    return manufacturer_id;
}
public void setManufacturer_id(Integer manufacturer_id) {
    this.manufacturer_id = manufacturer_id;
}
public String getManufacturer_name() {
    return manufacturer_name;
}
public void setManufacturer_name(String manufacturer_name) {
    this.manufacturer_name = manufacturer_name;
}

我有调试并看到该行:

if(detailManufacturer.getId() == id && detailManufacturer.getManufacturer_id() == manufacturer_id)

看起来这行不正确,请支持我,非常感谢...

1 个答案:

答案 0 :(得分:0)

那些是输出结果日志

ID(CARID)| NAME |价格| MANUFACTURER_ID | MANUFACTURER_NAME

1  Cho thue xe Honda  20000  1  Honda
2  Cho thue xe Honda  10000  2  Toyota
3  Cho thue xe Honda  30000  3  Huyndai
4  Cho thue xe Honda  66000  4  BMV
643  Cho thue xe Huyndai  200000  3  Huyndai
661  Cho thue xe Huyndai  150000  4  BMV
642  Cho thue xe Huyndai  210000  2  Toyota
641  Cho thue xe Huyndai  66000  1  Honda
607  Cho thue xe Mescedes  210000  6  Kia Morning
610  Cho thue xe Mescedes  200000  7  Luxus
621  Cho thue xe Mescedes  150000  5  Mercedes
581  Cho thue xe Mescedes  200000  4  BMV
546  Cho thue xe Toyota2   000002  5  Mercedes
547  Cho thue xe Toyota1  210000  6  kia Morning
548  Cho thue xe Toyota2  400000  7  Luxus
549  Cho thue xe Toyota3  500000  1  Honda
550  Cho thue xe Toyota4  300000  2  Toyota
551  Cho thue xe Toyota5  3233333  3  Huyndai

然而,JSON没有结果,这是警告:响应是空的