nested exception is java.lang.NullPointerException
2018-02-15 18:49
477 查看
可能的原因是没有添加 @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";
}
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";
}
相关文章推荐
- Could not open JPA EntityManager for transaction; nested exception is java.lang.NullPointerException
- Unknown jedis exception; nested exception is java.lang.NullPointerException
- [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
- Request processing failed; nested exception is java.lang.NullPointerException
- ?--Porg.springframework.beans.MethodInvocationException: Property 'username' threw exception; nested exception is java.lang.NullPointerException
- Request processing failed; nested exception is java.lang.NullPointerException] with root cause
- nested exception is java.lang.NullPointerException
- threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with
- Request processing failed; nested exception is java.lang.NullPointerException
- Request processing failed; nested exception is java.lang.NullPointerException] with root cause
- Request processing failed; nested exception is java.lang.NullPointerException
- HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException
- HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException
- HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException
- error:org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
- Cannot get Jedis connection; nested exception is java.lang.NullPointerException
- HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException
- Request processing failed; nested exception is java.lang.NullPointerException
- Retrofit +RxJava2 出现 java.lang.NullPointerException: Null is not a valid element
- java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.widget.CheckBox.is