日期:2014-05-20  浏览次数:20775 次

Action中为什么不调用Service里面的方法?
Action中:
private IConfigQuestionFirstKindService cqfService;
private IConfigQuestionSecondKindService cqsService;


/** 
* 跳转到试题登记页面
* Method toAdd
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward toAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List<ConfigQuestionFirstKind> cqfLists = cqfService.lists();
List<ConfigQuestionSecondKind> cqsLists = cqsService.lists();
request.setAttribute("cqfLists", cqfLists);
request.setAttribute("cqsLists", cqsLists);
return mapping.findForward("add");
}
报:java.lang.NullPointerException
at com.youcai.y243.struts.action.EngageSubjectsAction.toAdd(EngageSubjectsAction.java:53)

------解决方案--------------------
cqfService 和 cqsService 都是被初始化成了null , 调用其中方法肯定NullPointerException