可能的原因是没有添加 @Autowired 注解,加上即可。
public class PropertyController { @Autowired PropertyService propertyService; @Autowired CategoryService categoryService; @RequestMapping("admin_property_list") public String list(int cid ,Model model, Page page) { Category c = categoryService.get(cid); System.out.println(cid); List<Property> cs = propertyService.list(cid); PageHelper.offsetPage(page.getStart(),page.getCount()); int total = (int)new PageInfo<>(cs).getTotal(); page.setTotal(total); page.setParam("&cid="+c.getId()); model.addAttribute("ps", cs); model.addAttribute("cid", cid); model.addAttribute("page", page); return "admin/listProperty1"; }