首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

Action中为什么不调用Service里面的方法?解决思路

2012-01-26 
Action中为什么不调用Service里面的方法?Action中:private IConfigQuestionFirstKindService cqfServicep

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 了

热点排行