appointment.html頁面表格:
控制器:
@controller
@RequestMapping("/appointment")
public String appointment(Model model) {
List results= appointService.getAppoint();
logger.info("開始獲取後台預約信息!");
for (Appoint appoint : results) {
System.out.println(appoint);
}
model.addAttribute("appoints",results);
return "appointment";
}
實體類:
public class Appoint implements Serializable{
private long appointId;
private String name;
private String telphone;
private Integer studentNumber;
private String school;
private String telphoneTwo;
private Integer lectureNumber;
//getter和setter及toString方法省略
}
報錯:
org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 0): Property or field 'appointId' cannot be found on null;
開發工具及框架:
idea2016.2.5、springboot1.4.2+thymeleaf2.1.5+springMVC+SqlServer2008
其它描述:foreach循環能夠正確的打印出實體集合,
Appoint{appointId=210, name='sdf ', telphone='asdf ', studentNumber=3, school='asdf', telphoneTwo='asdf ', lectureNumber=4}
但是在實體類裡idea提示getter方法沒有被使用,且html頁面循環體下的循環變量appoint提示Cannot resolve 'appoint'...。
你的tr是不是要把td包裹起來