我用javascript向grails服务器发送一个字符串值,值为:“0.5”
$.post(myURL,{scale:"0.5"},fnPost);
当我将其转换为以下内容时:
Long scale= params?.scale as Long ;
我得到:
For input string: "0.5". Stacktrace follows:
java.lang.NumberFormatException: For input string: "0.5"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:419)
at java.lang.Long.valueOf(Long.java:525)
真的,在常规中看到“0.5”不能转换为 Long 很奇怪!