el表达式 字符串转数字
时间: 2023-08-24 22:12:28 浏览: 207
EL表达式中可以使用内置的函数进行字符串转数字的操作。其中,`fn:toInt`函数可以将字符串转换为整数,`fn:toFloat`函数可以将字符串转换为浮点数。例如:
```
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
...
<c:set var="strnum" value="123" />
<c:set var="num1" value="${fn:toInt(strnum)}" />
<c:set var="num2" value="${fn:toFloat(strnum)}" />
```
在上述代码中,`strnum`是一个字符串类型的变量,通过`fn:toInt`函数将其转换为整数类型的变量`num1`,通过`fn:toFloat`函数将其转换为浮点数类型的变量`num2`。
#### 引用[.reference_title]
- *1* *2* [数字转字符串,字符串转数字](https://blog.csdn.net/coolwriter/article/details/80076801)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [9.5 JSP之表达式语言(EL)](https://blog.csdn.net/Michaelia_hu/article/details/90242605)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文