开发者

Google Web Toolkit Evaluate String

开发者 https://www.devze.com 2023-02-18 22:20 出处:网络
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? Becaus

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消