我得到这个错误,我该如何解决?

时间:2015-06-22 06:59:25

标签: grails

//if day is sat/sun, set value to W. calendar.set(year,monthNumberForCalendar,dayOfMonth) if(contract.workingDays.id == mondayToFriday.id)
       {                                  
         if(calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ monthMap.put(dayOfMonth, "W")

    URI
        /oulhr/leaveView/show
    Class
        java.lang.NullPointerException
    Message
        Cannot get property 'id' on null object

    //leaveMonths = this.getLeaveMonths(year)    
        def employeeContract = new Contract()
            employeeContract = this.getCurrentContract(employee) leaveMonths = this.getLeaveMonths(year,employeeContract) 

    /*add leave days to month(e.g Jan). When jan is filled up, add to the following month(.e.g Feb)   */       
       int monthNumber = 0;

1 个答案:

答案 0 :(得分:0)

错误消息很明确。

这是因为workingDaysmondayToFriday为空。

自信地说:
 contract.workingDays.id = mondayToFriday.id

您必须先确保contract, contract.workingDays, mondayToFriday不是null