Google Web Toolkit Evaluate String
I am trying out google web toolkit for the first time by making a simple calculator app. I have a string I need to e开发者_Python百科valuate, for example "123+32". How can I do this with GWT?
Because GWT is java, you'll have to split your string, in 123
+
32
, then turn the numeric strings into actual integers (Integer.parseInt
) and then based on the operator string actually do the sum.
I'm guessing you could also use JSNI and do a javascript eval
on the string, but remember that's very dangerous unless you validate the user input, as they might end up running arbitrary code.
精彩评论