NutzCN Logo
问答 表单提交时出现空指针异常。
发布于 2169天前 作者 qq_152b6ff2 2397 次浏览 复制 上一个帖子 下一个帖子
标签:

请问一下空指针异常是什么原因。

@IocBean
@At("/sbztxx")
@Filters
public class action {
	@Inject
	protected Dao dao;
	Log log = Logs.get();
	
	@At
    public Object insert(@Param("naturename")String name,@Param("idcard")String idCard,@Param("sqraddress")String sqrAddress,@Param("lxr")String lxrName,@Param("lxrsj")String lxrSj, QfgCompanyInfo qci,HttpServletRequest request, HttpSession session) {
        qci.setStNatureName(name);
        qci.setStIdCard(idCard);
		qci.setStApplyAddress(sqrAddress);
        qci.setStContactName(lxrName);
        qci.setStContactCellPhone(lxrSj);
        qci = dao.insert(qci);
        return qci;
    }
}

5 回复
WARN 15:48:23 FailProcessor.process(28)-->Error@/sbztxx/insert :
java.lang.NullPointerException
	at com.wonders.ghqfg.support.design.action.insert(action.java:28)
	at com.wonders.ghqfg.support.design.action$$FASTCLASS._invoke(action.java:1)
	at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
	at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
	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:198)
	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:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Thread.java:619)

28行是哪一行?

qci.setStNatureName(name);

所以qci是空咯. 改成局部变量

	@At
    public Object insert(@Param("naturename")String name,@Param("idcard")String idCard,@Param("sqraddress")String sqrAddress,@Param("lxr")String lxrName,@Param("lxrsj")String lxrSj,HttpServletRequest request, HttpSession session) {
        QfgCompanyInfo qci = new QfgCompanyInfo();
        qci.setStNatureName(name);
        qci.setStIdCard(idCard);
		qci.setStApplyAddress(sqrAddress);
        qci.setStContactName(lxrName);
        qci.setStContactCellPhone(lxrSj);
        qci = dao.insert(qci);
        return qci;
    }

PS: 这类名能不能改得规范一点点

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