request.getAttribute()的数据类型转换问题
生活随笔
收集整理的這篇文章主要介紹了
request.getAttribute()的数据类型转换问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
request.getAttribute("")返回的是object類型
int amount =(int)request.getAttribute("buyamount");
這種的轉換方式一直會報錯,需要強制解封裝:
int amount = Integer.parseInt(request.getAttribute("buyamount").toString());
轉float類型也是一樣的道理
float money = Float.parseFloat(request.getAttribute("moneyamount").toString());
?
總結
以上是生活随笔為你收集整理的request.getAttribute()的数据类型转换问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Leetcode--347. 前k个高频
- 下一篇: Leetcode--837. 新21点(