2014-04-01 2 views
0

에 의해 호출 될 때 속성이없는 객체를 반환하는 Java Restful 웹 서비스가 있습니다. JSON 개체는 아래에서 볼 수 있습니다.정상적인 서비스가 정상적으로 반환되지 않습니다.

아래 이미지는 나머지 기능에서 반환되기 직전의 개체를 보여줍니다. 보시다시피 요일에는 우편 배달부에 나타나지 않는 가치가 있습니다.

backAbsence 엔티티는이 게시물의 끝에서 볼 수 있습니다.

SAbsencebackAbsence 엔티티의 목록입니다.

내가 왜 SAbsenece을 반환 할 때 전체 모델이 우편 배달부에서 수신되지 않고 어떻게 해결해야합니까?

enter image description here

[ 
    { 
     "name": "King sean", 
     "classidClass": 0, 
     "studentidStudent": 1, 
     "week": 14 
    }, 
    { 
     "name": "Sean king", 
     "classidClass": 0, 
     "studentidStudent": 2, 
     "week": 14 
    } 
] 
나머지 기능 부 :

@GET 
    @Produces({"application/xml","application/json"}) 
    @Path("{id}/{option}") 
    public List<BackAbsence> findbyClass(@PathParam("id")int id, 
            @PathParam("option")int option) { 

List<BackAbsence> SAbsence = new ArrayList<>(); 

// code here fills list. The Image above shows the object with valid attributes 
return SAbsence; 
    } 


} 

BackAbsnece 법인 :

public class BackAbsence { 

    private String name; 

    public String getName() { 
     return name; 
    } 

    public void setName(String name) { 
     this.name = name; 
    } 

    private int classidClass; 

    private int studentidStudent; 

    private int monday = 0, tuesday = 0, wednesday = 0, thursday = 0, friday = 0; 

    private int week; 

    public BackAbsence() { 
    } 

    public BackAbsence(int idstudent, String name) { 
    this.studentidStudent = idstudent; 
    this.name = name; 
    } 

    public BackAbsence(int classidClass, int studentidStudent, int monday, int tuesday, int wednesday, int thursday, int friday,int week) { 
     this.classidClass = classidClass; 
     this.studentidStudent = studentidStudent; 
     this.monday = monday; 
     this.tuesday = tuesday; 
     this.wednesday = wednesday; 
     this.thursday = thursday; 
     this.week = week; 
    } 

    public int isMonday() { 
     return monday; 
    } 

    public void setMonday(int monday) { 
     this.monday = monday; 
    } 

    public int isTuesday() { 
     return tuesday; 
    } 

    public void setTuesday(int tuesday) { 
     this.tuesday = tuesday; 
    } 

    public int isWednesday() { 
     return wednesday; 
    } 

    public void setWednesday(int wednesday) { 
     this.wednesday = wednesday; 
    } 

    public int isThursday() { 
     return thursday; 
    } 

    public void setThursday(int thursday) { 
     this.thursday = thursday; 
    } 

    public int isFriday() { 
     return friday; 
    } 

    public void setFriday(int friday) { 
     this.friday = friday; 
    } 


    public int getClassidClass() { 
     return classidClass; 
    } 

    public void setClassidClass(int classidClass) { 
     this.classidClass = classidClass; 
    } 

    public int getStudentidStudent() { 
     return studentidStudent; 
    } 

    public void setStudentidStudent(int studentidStudent) { 
     this.studentidStudent = studentidStudent; 
    } 



    public int getWeek() { 
     return week; 
    } 

    public void setWeek(int week) { 
     this.week = week; 
    } 

} 

답변

1

hrm. 당신은 "부울"스타일의 getter를 사용하여 int 필드를 얻는다. 등 getMonday, getTuesday이를 변경하거나 bools에 정수를 변경

private int monday = 0, tuesday = 0, wednesday = 0, thursday = 0, friday = 0; 

시도.

2

json mapper 구현에서 변환을 수행하기 위해 사용하는 것은 java bean 스타일 getters 및 setters 만 찾고 있으므로 isMonday()와 같은 int 메소드는 무시합니다. getMonday()로 변경하거나 다른 매퍼 구현을 찾으십시오.

관련 문제