java.lang.NumberFormatException

java.lang.NumberFormatException: For input string: "bDate" 这是什么原因啊 ,在线急等,帮忙支支招啊大神们

bDate不是数字,转换异常

数据转换错误了,你要转换的内容不符合数值类型,自己看日志,定位错误

1、错误描述

Exception in thread "main" java.lang.NumberFormatException: For input string: "61.13226212525146"
at java.lang.NumberFormatException.forInputString(NumberFormatExcepti......
答案就在这里:java.lang.NumberFormatException
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?

 public String execute() throws Exception{
        ActionContext context=ActionContext.getContext();
        Map session=context.getSession();
        System.out.println("123456789"+ordersNo);

        List olist=bosi.getOrders(ordersNo);


       // System.out.println("tejgh1265"+olist.get(0).getBillname());

        session.put("olist", olist);


        return Action.SUCCESS;

    }

这是action中的代码

 public String execute() throws Exception{
        ActionContext context=ActionContext.getContext();
        Map session=context.getSession();
        System.out.println("123456789"+ordersNo);

        List olist=bosi.getOrders(ordersNo);


       // System.out.println("tejgh1265"+olist.get(0).getBillname());

        session.put("olist", olist);


        return Action.SUCCESS;

    }

serviceimp的代码

 public List getOrders(String ordersNo) {
        HibernateTemplate ht=this.getHibernateTemplate();
        Session session=this.getSession();

        String sql="select * from t_orders t1,t_buy t2,t_book t3 where ordersNo='"+ordersNo+"' and t1.uNo=t2.uNo and t2.bookNo=t3.bookNo";
        //Query query=(Query) super.getSession().createQuery("from Orders t1,Buy t2,Book t3 where ordersNo='"+ordersNo+"' and t1.uNo=t2.uNo and t2.bookNo=t3.bookNo");
        Query query=super.getSession().createSQLQuery(sql);
        System.out.println("======================"+query.list().get(0));
        List list=query.list();
        return list;
    }

daoimp中的代码

这些代码里面都没有bDate这个变量或者属性,最好先搜索一下哪里出现了这个字符串,然后再看是不是对他进行了什么操作。

 <table bgcolor=#FFFF88 class="a" border="1" width="500px" height="450px">

<tr align="center"><td colspan="2">订单信息</td></tr>
<tr bgcolor="#FFFF88"><td colspan="2" align="center">购买时间:${sessionScope.olist.bDate }</td></tr>
<tr bgcolor=#FFFF88><td colspan="2" align="center">订单号:${sessionScope.olist.ordersNo }</td></tr>
<tr bgcolor="#FFFF88">
<td colspan="2" align="center">
<font color="GREEN" size="4">收货详情</font>
</td>
</tr>
<tr bgcolor=#FFFF88><td width="20%">
姓 名:</td><td>${sessionScope.olist.shipname }</td>
<tr bgcolor=#FFFF88><td width="20%">
电 话:</td><td>${sessionScope.olist.shipphone }</td>
<tr bgcolor=#FFFF88><td>
收 货 地 址:</td><td>${sessionScope.olist.shipaddr1 }</td>
</tr>
<tr bgcolor=#FFFF88><td>
省 份:</td><td>${sessionScope.olist.shipprovince}</td>
</tr>
<tr bgcolor=#FFFF88><td>
城 市: </td><td>${sessionScope.olist.shipcity}</td>
<tr bgcolor=#FFFF88><td>
邮 编:</td><td>${sessionScope.olist.shipzip }</td>
</tr>
</table>

页面输出

1、头上引入标签
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

2、
你把bDate用这个处理一下。
${sessionScope.olist.bDate },估计因为是日期类型,可能会将它转型为long型的数据,但如果日期格式带中文(年月日或者其他),就有问题了。
这是根据将字符串转化为Date类型时猜测的。最好是做一下处理。

<fmt:formatDate value="${project.creatDate }" pattern="yyyy-MM-dd"\/>

按这个<fmt:formatDate value="${project.creatDate }" pattern="yyyy-MM-dd"/>格式处理一下你的日期数据

把你的'购买时间:${sessionScope.olist.bDate }'改为
'购买时间:<fmt:formatDate value="${sessionScope.olist.bDate}" pattern="yyyy-MM-dd HH:mm:ss"/>'

 <table bgcolor=#FFFF88 class="a" border="1" width="500px" height="450px">

<tr align="center"><td colspan="2">订单信息</td></tr>
<tr bgcolor="#FFFF88"><td colspan="2" align="center">购买时间:<fmt:formatDate value="${sessionScope.olist.bDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td></tr>
<tr bgcolor=#FFFF88><td colspan="2" align="center">订单号:${sessionScope.olist.ordersNo }</td></tr>
<tr bgcolor="#FFFF88">
<td colspan="2" align="center">
<font color="GREEN" size="4">收货详情</font>
</td>
</tr>
<tr bgcolor=#FFFF88><td width="20%">
姓 名:</td><td>${sessionScope.olist.shipname }</td>
<tr bgcolor=#FFFF88><td width="20%">
电 话:</td><td>${sessionScope.olist.shipphone }</td>
<tr bgcolor=#FFFF88><td>
收 货 地 址:</td><td>${sessionScope.olist.shipaddr1 }</td>
</tr>
<tr bgcolor=#FFFF88><td>
省 份:</td><td>${sessionScope.olist.shipprovince}</td>
</tr>
<tr bgcolor=#FFFF88><td>
城 市: </td><td>${sessionScope.olist.shipcity}</td>
<tr bgcolor=#FFFF88><td>
邮 编:</td><td>${sessionScope.olist.shipzip }</td>
</tr>
</table>

你的olist.bDate格式是存的什么类型的数据?

哎 你没懂我的意思 你说你action 处理数据了 你根本没处理好吧 在action中遍历你的集合 获取到每个对象里的bDate 用new SimpleDateFormat("yy/MM/dd HH:mm").format(bDate);处理为String的 然后界面应该就不会有你那个错误了 你没理解 我也办法了 你自己找办法吧