我試圖將值「1」傳遞給Grails標記。然而,結果是一個49的整數值 - 「1」的ascii值。我如何將其轉換爲Groovy中的適當值?在Groovy中將Ascii轉換爲Int函數
0
A
回答
1
實際上,String上有一個「toInteger()」函數。
0
要添加到傑克BeNimble的評論,如果你正在使用1.2(發行版的情況例外),你也有空安全轉換爲int(即params.int(「值」),它會做
Convenient, null safe converters in params and tag attributes
New convenience methods have been added to the params object and tag attrs objects that allow the easy, exception safe and null safe conversion of parameters to common types:
def total = params.int('total')
There are methods for all the common base types such as [email protected], @[email protected], @boolean and so on. There is a special converter called list that always returns a list for cases when dealing with one or many parameters of the same name:
def names = params.list('names')
+0
我怎麼能有這樣的功能,INT()或長期()params對象爲全球在外打工? – Luccas 2011-04-01 05:07:45
+0
它與您如何定義增值稅有關。使用def的 不會使其成爲全球 由於某種原因,不使用def也可以使用 或者你可以寫出所有類似於java類的東西並且有字段。然後,元類的東西將只是假設在你創建了一個類的實例後訪問它們所需要的方法 – branchgabriel 2012-05-04 19:23:41
相關問題
- 1. 將ascii轉換爲int?
- 2. 將ascii substr轉換爲int
- 3. 將ASCII轉換爲int
- 4. 將ASCII轉換爲Int
- 5. 在Arduino中將ASCII轉換爲int
- 6. 無法將Int數組轉換爲ASCII
- 7. 如何在Groovy中將數組轉換爲int?
- 8. 將int函數強制轉換爲void *
- 9. 在C函數中將二進制轉換爲ASCII並將ASCII轉換爲字母?
- 10. 在C/C++中將int轉換爲ASCII碼
- 11. 在xquery中將十六進制轉換爲ascii的函數
- 12. C++將Ascii Int轉換爲字符到Int
- 13. 將數組中的值轉換爲ascii?
- 14. 在Haskell中將Maybe Int轉換爲Int
- 15. 在'C'中將int轉換爲int []
- 16. ASCII字符爲int的轉換用C
- 17. 轉換INT爲char *給ASCII值C++
- 18. 在JavaScript中將字符轉換爲ASCII
- 19. 在Rails中將變量轉換爲ASCII
- 20. 在LISP中將CHAR轉換爲ASCII碼
- 21. 將[Int?]轉換爲[Int]
- 22. 將int轉換爲int []
- 23. 將IO Int轉換爲Int
- 24. 如何將字符串轉換爲Groovy中的int
- 25. 是否有任何函數在PHP中將long轉換爲int?
- 26. 如何將int數組轉換爲int?
- 27. 在MIPS /彙編程序中將ASCII數字的字符串轉換爲int
- 28. Bash:將非ASCII字符轉換爲ASCII
- 29. 將unicode轉換爲ascii
- 30. 將ASCII MathML轉換爲LaTeX
這將有助於發佈代碼,因爲你的問題是幾乎可以肯定的語法。 – noah 2010-01-13 19:57:48