构建树的的字符串是报错Servlet.service() for servlet default threw exception

风雪满弓刀 发布于 2013/08/10 17:16
阅读 541
收藏 0
严重: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:406)
at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:906)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:586)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:619)


部分代码:

 报错的

  • public String getTbFocusSortsListAll() {
  • TbCodemaster sortBean = new TbCodemaster();
  • sortBean.setParentCode("0");
  • sortBean.setCode("PRO_030");
  • JSONArray carr = new JSONArray();
  • JSONObject root = new JSONObject();
  • root.put("text", "根目录(点击获取所有信息)");
  • root.put("id", "0");
  • root.put("expanded", true);
  • JSONArray rootarr = new JSONArray();
  • rootarr=getSubArrayLnn(sortBean);
  • root.put("children", rootarr);
  • carr.add(root);
  • return carr.toString();
  • }
  • /**
  •      * <summary>
  •      * 方法的概要说明:递归调用生成树
  •      *</summary>
  •      *@return JsonArray
  •      */
  • public JSONArray getSubArrayLnn(TbCodemaster sortBean){
  • List<TbCodemaster> sortList = tbCodemasterDao.selectTbCodemaster(sortBean);
  • JSONArray arr = new JSONArray();
  • if (null != sortList &&sortList.size() > 0) {
  • for (int i = 0; i <sortList.size(); i++) {
  • TbCodemaster subSortBean =  sortList.get(i);
  • JSONObject subobjone = new JSONObject();
  • subobjone.put("text", subSortBean.getMtype());
  • subobjone.put("id", subSortBean.getMcode());
  • List<TbCodemaster> sortListsub =  tbCodemasterDao.selectTbCodemaster(subSortBean);
  • if (null != sortListsub && sortListsub.size() > 0) {
  • subobjone.put("leaf", false);
  • subobjone.put("children", getSubArrayLnn(subSortBean));
  • } else {
  • subobjone.put("leaf", true);
  • }
  • arr.add(subobjone);
  • }
  • }
  • return arr;
  • }


没报错的

  • List<TbCodemaster> codemasterList = tbCodemasterDao.selectTbCodemaster(tbCodemaster);
  • return getJSONTree(codemasterList);


  • /**
  • * 获取跟元素调用递归
  • * @param List集合
  • * @return JSON String
  • * @throws DataAccessException
  • * @throws SecurityException
  • * @throws IllegalArgumentException
  • * @throws NoSuchMethodException
  • * @throws IllegalAccessException
  • * @throws InvocationTargetException
  • * @Date 2012-07-03
  • */
  • public String getJSONTree(List<TbCodemaster> codelist)
  • throws DataAccessException, SecurityException,
  • IllegalArgumentException, NoSuchMethodException,
  • IllegalAccessException, InvocationTargetException {
  • JSONArray carr = new JSONArray();
  • JSONObject root = new JSONObject();
  • root.put("text", "根目录");
  • root.put("id", "-1");
  • root.put("expanded", true);
  • JSONArray rootarr = new JSONArray();
  • for (int i = 0; i < codelist.size(); i++) {
  • JSONObject obj = new JSONObject();
  • obj.put("text", codelist.get(i).getMtype());
  • obj.put("expanded", true);
  • obj.put("id", codelist.get(i).getMcode());
  • if (getSubArray(codelist.get(i)).size() > 0) {
  • obj.put("leaf", false);
  • obj.put("children", getSubArray(codelist.get(i)));
  • }
  • else
  • {
  • obj.put("leaf", true);
  • }
  • rootarr.add(obj);
  • }
  • root.put("children", rootarr);
  • carr.add(root);
  • return carr.toString();
  • }
  • public JSONArray getSubArray(TbCodemaster codemaster)
  • throws DataAccessException, SecurityException,
  • IllegalArgumentException, NoSuchMethodException,
  • IllegalAccessException, InvocationTargetException {
  • TbCodemaster codemasterBean = new TbCodemaster();
  • codemasterBean.setParentCode(codemaster.getMcode());
  • List<TbCodemaster> codemasterList = tbCodemasterDao.selectTbCodemaster(codemasterBean);
  • JSONArray arr = new JSONArray();

  • if (null != codemasterList && codemasterList.size() > 0) {
  • for (int i = 0; i < codemasterList.size(); i++) {
  • TbCodemaster subcodemaster = codemasterList.get(i);
  • TbCodemaster codemasterBeansub = new TbCodemaster();
  • codemasterBeansub.setParentCode(subcodemaster.getMcode());
  • JSONObject subobjone = new JSONObject();
  • subobjone.put("text", subcodemaster.getMtype());
  • subobjone.put("id", subcodemaster.getMcode());
  • List<TbCodemaster> codemasterListsub = tbCodemasterDao.selectTbCodemaster(codemasterBeansub);
  • if (null != codemasterListsub && codemasterListsub.size() > 0) {
  • subobjone.put("leaf", false);
  • subobjone.put("children", getSubArray(subcodemaster));
  • } else {
  • subobjone.put("leaf", true);
  • }
  • arr.add(subobjone);
  • }
  • }
  • return arr;
  • }

报错的方法在其他类中使用时,没有出现错误,在这个类中出现错误。求高人解释一下

加载中
返回顶部
顶部