Json调用AJAX报错了 求大牛帮忙

qq_19701441 2015-07-19 05:18:53
代码
public void emailCheck() throws IOException{
HttpServletResponse response=ServletActionContext.getResponse();
response.setContentType("text/json;charset=GB18030");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out;
out = response.getWriter();
JSONObject json=new JSONObject();
EmailImpl ei;
this.emp=new Emp();
this.emp.setId(1);
this.emp.setName("DerrickJJ");
this.emp.setPassword("123456");
this.nowpage=0;
if(this.ka==0){
ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
ei=(EmailImpl)ac.getBean("emaildao");
this.list = ei.checkUnreadEmail(emp, nowpage);
System.out.println("ka=0");
this.list.get(0).setContent("未读");
}else if(this.ka==1){
ei=(EmailImpl)AppBeans.ac.getBean("emaildao");
System.out.println("ka=1");
this.list = ei.checkRecEmail(emp, nowpage);
this.list.get(0).setContent("收");
}else{
ei=(EmailImpl)AppBeans.ac.getBean("emaildao");
System.out.println("ka=2");
this.list = ei.checkSendEmail(emp, nowpage);
this.list.get(0).setContent("发");
}
EmailsendToOther eto = new EmailsendToOther();
ArrayList<EmailsendOther> listother = eto.emailsendToOther(list);
for(EmailsendOther eo:listother){
System.out.println(eo.getSendTime());
}
json.put("list",listother);
out.println(json);
out.flush();
out.close();
}

错误:严重: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407)
at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:753)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:506)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
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:230)
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:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:744)

测试了一下卡在json.put("list",listother);过不去了 listother对象是值得
...全文
112 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jcrs523 2015-07-20
排除法可以试试
回复
qingyuan18 2015-07-20
嵌套对象的json解析,换alibaba的fastJson jar包,那个支持这种嵌套List类型的
回复
qqw6789567 2015-07-20
blog.csdn.net/foamflower/article/details/4849308 看下这个帖子你就明白了!
回复
lorcx935200 2015-07-19
out.flush(); out.close(); 你把这注释掉试试
回复
心碎了无痕 2015-07-19
你可以试着用排除法排除。把报错的那句代码先注释,然后看看是否通过,一步一步定位。 希望对你有帮助。
回复
qq_19701441 2015-07-19
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-07-19 05:18
社区公告
暂无公告