-1
我在Restful WebService中有一个方法,它根据ID打印给定记录的所有信息。打印方法中的NullPointerException
当我测试这个方法时,我得到一个NullPointerException。
@SuppressWarnings("null")
@RequestMapping("print")
@ResponseBody
public ResponseEntity<Map<String, Object>> print(@RequestParam("id") Long id) {
Map<String, Object> mapPrint=null;
ResourceManage resourceManage = resourceManageService.findByIdwithowner(id);
Map<String, Object> params = new HashMap<String, Object>();
if (resourceManage.getDocumentOwner() != null && resourceManage.getDocumentOwner().getId() != null)
params.put("documentOwner", resourceManage.getDocumentOwner().getId());
else
params.put("documentOwner", null);
params.put("resId", id);
mapPrint.put("format", "pdf");
mapPrint.put("reportQuery", resourceManageService.generateReportQuery(params));
return new ResponseEntity<Map<String, Object>>(mapPrint, HttpStatus.OK);
}
在这行你得到的NPE? – Christian
你也应该提供一个这种方法的示例调用,它会导致NPE。 –
可能重复[什么是NullPointerException,以及如何解决它?](http://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it ) – Jens