繁体   English   中英

c:set变量上的数学

[英]maths on c:set variables

挣扎于某些c:set语法(JSP / Eclipse中的JSTL)

select / when(if)部分和初始c:set设置为row.sensorvalue可以正常工作,但比对变量进行数学运算的任何尝试都会导致公式(而不是结果)最终以十进制值和实际值结尾。

任何帮助表示赞赏

<c:when test = "${row.typename == 'Temperature'}">

<c:set var = "initialvalue" value="${row.sensorvalue}" />

<c:set var="decimalvalue" value="${initialvalue}*0.1875"/>

<c:set var="actualvalue" value="((10.888 - SQRT((-10.888)^2 +4*0.0035*(1777.3-${decimalvalue})))/(2*-0.00347) + 30)"/>

<td><c:out value="${actualvalue}"/></td>

</c:when>

问候拉尔夫

确实做到了在片段中做到这一点(混乱,但后来我不假装自己是一名开发人员)-

<%
String morecalcs = pageContext.getAttribute("calculatedvalue").toString();

//string to float
float forroot = Float.parseFloat(morecalcs);

//integer part for square root calcs
float fractionalPart = forroot % 1;
float integralPart = forroot - fractionalPart;

// square roote calcs
double actualvalue = (10.888 - Math.sqrt(Math.pow(-10.888, 2) +4*0.0035*(1777.3-integralPart)))/(2*-0.00347) + 30;

//1 decimal place
double rounded1 = Math.round(actualvalue * 10) / 10.0;
pageContext.setAttribute("finalvalue", rounded1);
%>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM