报错信息
2017-11-18 14:46:11,552 [http-nio-8080-exec-8] ERROR org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler - Exception occurred during processing request: null
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.valueOf(Integer.java:766)
at cn.sx.action.PaymentAction.paymentadd(PaymentAction.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:870)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1293)
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:117)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at java.lang.Thread.run(Thread.java:745)action类:
public class PaymentAction extends ActionSupport{

private PaymentService paymentService;

public void setPaymentService(PaymentService paymentService) {
this.paymentService = paymentService;
}

private HttpServletRequest request = ServletActionContext.getRequest();        /**
 * 缴费信息添加
 */
public String paymentadd(){
String proid = request.getParameter("property");
String type = request.getParameter("type");
String paycycle = request.getParameter("paycycle");
String cost = request.getParameter("cost");
String re = request.getParameter("re");

Property pro = paymentService.findprobean(Integer.valueOf(proid));


Payment pay = new Payment();

pay.setProperty(pro);
pay.setType(type);
pay.setPaycycle(paycycle);
pay.setCost(cost);
pay.setRe(re);
pay.setPaymentlock(0);
pay.setCreatetime(new Date());
pay.setPaytime(new Date());

paymentService.insertpayment(pay);

return "repaymentlist";
}
service类:
@Transactional
public class PaymentService {

private PaymentDao paymentDao; public void setPaymentDao(PaymentDao paymentDao) {
this.paymentDao = paymentDao;
}
         public Property findprobean(Integer proid) {
return paymentDao.findprobean(proid);
}
dao类:
public interface PaymentDao { Property findprobean(Integer proid);}dao实现类:
public class PaymentDaoImpl extends HibernateDaoSupport implements PaymentDao {
public void insertpayment(Payment pay) {
this.getHibernateTemplate().save(pay);
} public Property findprobean(Integer proid) {
List<Property> list = (List<Property>) this.getHibernateTemplate().find("from Property where proid  = ?", proid);
if (list!=null && list.size()!=0) {
return list.get(0);
}
return null;
}spring:
<bean id="paymentAction" class="cn.sx.action.PaymentAction" scope="prototype">
<property name="paymentService" ref="paymentService"></property>
</bean> <bean id="paymentService" class="cn.sx.service.PaymentService" scope="prototype">
<property name="paymentDao" ref="paymentDaoImpl"></property>
</bean> <bean id="paymentDaoImpl" class="cn.sx.dao.PaymentDaoImpl" scope="prototype">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
我用断点找了,结果是显示
求助大神!!

解决方案 »

  1.   

    java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:542)
        at java.lang.Integer.valueOf(Integer.java:766)
        at cn.sx.action.PaymentAction.paymentadd(PaymentAction.java:86)
    PaymentAction的86行,打印proid是否为null???
      

  2.   

    断点显示的是paymentDao为空,proid是有值的
      

  3.   

    应该是proid为null,报错的是Integer.valueOf()这个方法,不知道楼主是怎么调试出dao为null的
      

  4.   

    java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:542)
        at java.lang.Integer.valueOf(Integer.java:766)
        at cn.sx.action.PaymentAction.paymentadd(PaymentAction.java:86)   这里报错信息比较明显了,PaymentAction这个类的86行,前面报转化失败,那应该传了个错误的类型或者null过来了
      

  5.   

    java.lang.NumberFormatException: null  看看你那个action  是不是有值   
      

  6.   

     List<Property> list = (List<Property>) this.getHibernateTemplate().find("from Property where proid  = ?", proid);
            if (list!=null && list.size()!=0) {
                return list.get(0);
            }
            return null;看看你这个list是不是为null  如果为null 那么你返回的就是null   当然最后null不能转为数字就会报哪个错啊
      

  7.   

    java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:542)这该是参数问题吧
      

  8.   

    at cn.sx.action.PaymentAction.paymentadd(PaymentAction.java:86)
    这行代码是啥
      

  9.   

    在dao的头上有@service 没有 或者错了都走不进去