<c:set var="ordertotalmoney" value="${sorder.so_bzmoney+ordertotalmoney}"/>
因为sorder.so_bzmoney定义的是String 类型,并带有小数点,例值:2800.12
我需要对他的值和ordertotalmoney定义的变量相加,怎么处理?
直接加有异常 
javax.servlet.jsp.el.ELException: An exception occured trying to convert String "0.00" to type "java.lang.Long"

解决方案 »

  1.   

    jstl标签里有数据格式处理标签,可以先进行格式处理吧
      

  2.   

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <%@ page import="org.test.Price" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <% 
    Price price = new Price();
    price.setValue("45.3");
    String test = "12.44";
    request.setAttribute("price", price);
    request.setAttribute("test", test);%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <link rel="icon" type="image/x-icon" href="favicon.ico" /> 
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <c:set var="result" value="${test + price.value}"></c:set>
    ${result}</body>
    </html>package org.test;public class Price {
    private String value; public String getValue() {
    return value;
    } public void setValue(String value) {
    this.value = value;
    }
    }没有任何问题啊
      

  3.   


    问题已经找到是
    An exception occured trying to convert String "0.00" to type "java.lang.Long"
    667: <c:if test="${sorder.so_money>0}">的错误,
    改成<c:if test="${sorder.so_money>0.00}">就可以了