NutzCN Logo
问答 关于自定义sql的问题?包空指针
发布于 148天前 作者 qq_1786ffc1 119 次浏览 复制 上一个帖子 下一个帖子
标签:
for(int id:ids){
	    	        			cmsWenjuanService.delete(id);
	    	        			
	    	        			Sql sql=Sqls.create("delete from cms_wenjuan_wenti where wj_id=@wj_id");
	    	        			sql.params().set("wj_id", id);
	    	        			dao.execute(sql);
	    	        		}
12 回复

具体报错信息

@At({"/delete/?", "/delete"})
	    @Ok("json")
	    /*@SLog(tag = "删除模板", msg = "ID:${args[2].getAttribute('id')}")*/
	    public Object delete(@Param("ids") int [] ids, HttpServletRequest req,Dao dao) {
	        try {	System.out.println("===================="+ids.toString());
	        		
	            	/*cmsWenjuanService.delete(ids);*/
	    	    	for(int id:ids){
	    	    		Trans.exec(new Atom(){//事务
		            	    public void run() {
	    	        			cmsWenjuanService.delete(id);
	    	        			
	    	        			Sql sql=Sqls.create("delete from cms_wenjuan_wenti where wj_id=@wj_id");
	    	        			sql.setParam("wj_id", id);
	    	        			System.out.println("sqlsql:"+sql.toString());
	    	        			dao.execute(sql);
	    	        			
		            	    }
		            	});
	        		}
	            return Result.success("system.success");
	        } catch (Exception e) {
	        	System.out.println("错误日志"+e.toString());
	            return Result.error("system.error");
	        }
	    }

====================[I@1e1b360e
2017-07-20 11:20:43,767 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - DELETE FROM cms_wenjuan WHERE wj_id=?
| 1 |
|-----|
| 104 |
For example:> "DELETE FROM cms_wenjuan WHERE wj_id=104"
sqlsql:delete from cms_wenjuan_wenti where wj_id=104
错误日志java.lang.NullPointerException

是dao的原因吗

} catch (Exception e) {
	        	log.debug(e.getMessage(), e);
	               return Result.error("system.error");
	        }

这样才能打印详细日志

2017-07-20 11:31:33,587 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - DELETE FROM cms_wenjuan WHERE wj_id=?
| 1 |
|-----|
| 104 |
For example:> "DELETE FROM cms_wenjuan WHERE wj_id=104"
sqlsql:delete from cms_wenjuan_wenti where wj_id=104
2017-07-20 11:31:33,642 cn.zjucd.app.web.modules.controllers.platform.cms.CmsWenjuanController.delete(CmsWenjuanController.java:271) DEBUG -
java.lang.NullPointerException
at cn.zjucd.app.web.modules.controllers.platform.cms.CmsWenjuanController$1.run(CmsWenjuanController.java:264)
at org.nutz.trans.Trans.exec(Trans.java:174)
at org.nutz.trans.Trans.exec(Trans.java:132)
at cn.zjucd.app.web.modules.controllers.platform.cms.CmsWenjuanController.delete(CmsWenjuanController.java:257)
at cn.zjucd.app.web.modules.controllers.platform.cms.CmsWenjuanController$FM$delete$12616f619b550cd75a5922f84704926a.invoke(CmsWenjuanController.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 cn.zjucd.app.web.commons.processor.XssSqlFilterProcessor.process(XssSqlFilterProcessor.java:35)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at cn.zjucd.app.web.commons.processor.NutShiroProcessor.process(NutShiroProcessor.java:50)
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.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at cn.zjucd.app.web.commons.processor.GlobalsSettingProcessor.process(GlobalsSettingProcessor.java:34)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at cn.zjucd.app.web.commons.processor.LogTimeProcessor.process(LogTimeProcessor.java:18)
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:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at cn.zjucd.app.web.commons.filter.RouteFilter.doFilter(RouteFilter.java:27)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:277)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2381)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2370)
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)
2017-07-20 11:31:33,800 org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.manage(JobStoreSupport.java:3877) DEBUG - ClusterManager: Check-in complete.
2017-07-20 11:31:53,804 org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.manage(JobStoreSupport.java:3877) DEBUG - ClusterManager: Check-in complete.

等等, 为毛你声明个Dao dao参数, 去掉!!

不声明,我没有dao可以用啊,哈哈

哈哈哈 解决了,再次感谢

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