严重: Servlet.service() for servlet default threw exception 什么意思 20
严重:Servlet.service()forservletdefaultthrewexceptionjava.lang.NullPointerExceptionatco...
严重: Servlet.service() for servlet default threw exception
java.lang.NullPointerException
at com.shopping.web.action.CompanyAction.register(CompanyAction.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
..............................
求大神看看这段对不对:
// 用户注册
public String register() throws Exception {
ZeeCompany company = new ZeeCompany();
company.setLoginname(loginname);
company.setPassword(password);
company.setQuestion(question);
company.setAnswer(answer);
company.setConame(coname);
company.setCoweb(coWeb);
company.setColeglman(coLeglman);
company.setColinkman(colinkman);
company.setCotel(cotel);
company.setCofax(cofax);
company.setComail(comail);
try {
ZeeProvince pro = companyService.findProvinceById(province);
ZeeCity c = companyService.findCityById(city);
System.out.println(pro.getId());
System.out.println(c.getId());
company.setZeeCity(c);
company.setZeeProvince(pro);
companyService.register(company);
return "register-true";
} catch (ServiceException e) {
addActionError(e.getMessage());
e.printStackTrace();
return "register-false";
}
} 展开
java.lang.NullPointerException
at com.shopping.web.action.CompanyAction.register(CompanyAction.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
..............................
求大神看看这段对不对:
// 用户注册
public String register() throws Exception {
ZeeCompany company = new ZeeCompany();
company.setLoginname(loginname);
company.setPassword(password);
company.setQuestion(question);
company.setAnswer(answer);
company.setConame(coname);
company.setCoweb(coWeb);
company.setColeglman(coLeglman);
company.setColinkman(colinkman);
company.setCotel(cotel);
company.setCofax(cofax);
company.setComail(comail);
try {
ZeeProvince pro = companyService.findProvinceById(province);
ZeeCity c = companyService.findCityById(city);
System.out.println(pro.getId());
System.out.println(c.getId());
company.setZeeCity(c);
company.setZeeProvince(pro);
companyService.register(company);
return "register-true";
} catch (ServiceException e) {
addActionError(e.getMessage());
e.printStackTrace();
return "register-false";
}
} 展开
展开全部
java.lang.NullPointerException
空指针异常,你debug一下看42行,是不是某个变量有空值
空指针异常,你debug一下看42行,是不是某个变量有空值
追问
就是用户注册中的
try {
ZeeProvince pro = companyService.findProvinceById(province);
ZeeCity c = companyService.findCityById(city);
42行 System.out.println(pro.getId());
System.out.println(c.getId());
追答
看一下province是否为空值
或者 findProvinceById 方法 执行有误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
您找到42行代码 把那代码发来
更多追问追答
追问
就是用户注册中的
try {
ZeeProvince pro = companyService.findProvinceById(province);
ZeeCity c = companyService.findCityById(city);
42行 System.out.println(pro.getId());
System.out.println(c.getId());
追答
ID没GET出来 findCityById(city);没返回ID吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询