代码:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//验证是否登录以及权限

if(!(check.isRights(request, response)).equals("OK")){
check.redirectError(request, response, "error.do?base64=true&errMsg=" +check.isRights(request, response));
return null;
}else{
boolean isData = false;
int pageSize = Constants.PAGE_SIZE;
String page = request.getParameter("page");
page = (page == null) ? "1" : page.trim();
ComList iterator = new ComList();
ComParam param ;
String pageStr = "";
int totalNum = pageService.getCount();
String dbPageAttr[] = dbPage.getPageInfo(totalNum + "", pageSize, page,"rights_man.do?");
pageStr = dbPageAttr[2];
List queryList = pageService.getQuery(Integer.parseInt(dbPageAttr[0]), pageSize);
String fatherTmp = "";
if(queryList  != null && queryList.size()>0){
List list = new ArrayList();
TPrivilege privilege ;
String bgColor = "#ffffff";
Hashtable fatherRights = dbService.getFatherRights();
for (int i = 0; i < queryList.size(); i++) {
bgColor = ((i%2) == 0)?"#ffffff":"#eaeaea";
privilege = (TPrivilege) queryList.get(i);
param = new ComParam();
param.setParam0(bgColor);
param.setParam1(privilege.getPrvid());
param.setParam2(privilege.getPrvname());
param.setParam3(privilege.getUrl());
try {
fatherTmp = fatherRights.get(privilege.getPareventId()).toString();
} catch (Exception e) {
fatherTmp = "父级数据丢失...";
}
param.setParam4(fatherTmp);
param.setParam4((privilege.getStatus().intValue() == 1)?"启用":"禁用");
param.setParam4((privilege.getIssys().intValue() == 1)?"disabled = \"disabled\"":"");//是否是系统固定菜单,固定菜单将不可删除
list.add(param);
}
iterator.setParamList(list);
fatherRights = null;
privilege = null;
isData = true;
}
request.setAttribute("ComList", iterator);
if(isData){
PagesInfo pageInfo = new PagesInfo();
pageInfo.setPageInfo(pageStr);
request.setAttribute("PageInfo", pageInfo);
}else{
InfoTips infoTips = new InfoTips();
infoTips.setTipsInfo("No data");
request.setAttribute("InfoTips", infoTips);
}
iterator = null;
}
return mapping.findForward("rights_main");
}       private Hashtable out(){
String key = "hello";
Object obj = "Java";
Hashtable table = new Hashtable();
table.put(key, obj);
return table;
}
插入断点之后,我执行到TPrivilege privilege ;
String bgColor = "#ffffff";之后,断点就停止了,但没进入到dbService.getFatherRights()方法里(dbService.getFatherRights()这个方法里也插入了断点),我换成别的方法,将相关代码改成如下:fatherRights = out();
结果跟原来的一样,还是没用执行out这个方法,跪求大神指点呀,泪奔中...~~~~(>_<)~~~~ 

解决方案 »

  1.   

    错误信息是:
    java.lang.NullPointerException
    at org.web.action.Rights_mainAction.execute(Rights_mainAction.java:71)
    at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)
    at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
    at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
    at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
    at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
    at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    指的是Hashtable fatherRights为空,因为没有执行dbService.getFatherRights();里面的方法,所以为空,问题是:为什么没有执行这个方法呢?我把方法换成别的方法,结果还是没用执行,为什么啊?多谢大哥指点啊,O(∩_∩)O~
      

  2.   

    我的猜测是dbService为空,所以抛空指针,你换成调用其他方法后IDE没有重新编译导致没有被执行
      

  3.   

    大哥就是大哥啊,我跟踪了一下,dbService确实为空,导致没法执行。原因是IOC中没有绑定dbService,现在绑定了,问题就消失了啊,呵呵,谢谢你,结贴吧。