NutzCN Logo
问答 Ajax传递数组 nutz后台接收空指针问题
发布于 2782天前 作者 TIL-MICE 2187 次浏览 复制 上一个帖子 下一个帖子
标签:
2017-05-11 21:04:57,180 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) WARN  - Error@/score/saveScores :
java.lang.NullPointerException
	at com.lckiss.ScoresModule.saveScores(ScoresModule.java:77)
	at com.lckiss.ScoresModule$FM$saveScores$a7b9582ef0bb13efe83d6e54c3a39614.invoke(ScoresModule.java)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

这是后台代码

  @At
  @Ok("raw")
  public String saveScores(@Param("ids")String[ ] ids,@Param("s2")String[ ]   uda,@Param("ksid") String ksid,HttpSession session) {
        User u=(User) session.getAttribute("me");
        System.out.println("--------------------------");
        System.out.println(uda.length);
        System.out.println(ids.length);
        

这是前台代码和发送方式

                              var s1=new Array();
                              var s2=new Array();
                              for (var i =0; i <chkNum-1; i++) {
                                    s1[i] = ti_id[i+1].id;
                                    s2[i] = u_da[i+1];
                              }
                          //    s1[i] = ti_id[i].id;
                             // s2[i]= u_da[i];
                              $.ajax({
                                    type: "POST",
                                    url: "${ctxPath}/score/saveScores",
                                    data: { 'ids': s1, 's2': s2, 'ksid': ksid },

单个元素没问题,duoge便无法接收,输出长度直接空指针,debug为null,
前台js调试2个数组并没什么问题

是要用json还是说注解要换成其他的,还请不厌其烦的帮助下新手.赶集不尽

2 回复
添加回复
请先登陆
回到顶部