這是我的jstl版本
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
我想像在 Java 中一樣從 double 轉換為 int。
${(int)(Math.toDegrees(city.latitude))}
但我抓住
[javax.el.ELException: Failed to parse the expression [${(int)(Math.toDegrees(city.latitude))}]] with root cause
uj5u.com熱心網友回復:
JSTL ... 或更準確地說 EL ... 不支持 Java 顯式型別轉換語法。
但在這種情況下,您應該能夠實作您想要的結果,如下所示:
${Double.valueOf(Math.toDegrees(city.latitude)).intValue()}
該方法提供與原始縮小intValue()轉換相同的值......這正是強制轉換所做的。int
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/427212.html
