我已经实现了一些可以正常工作的服务。该服务具有以下属性:不能从字符串转换为整数
@Property(name = MyService.PROXY_PORT, label = "Proxy Port", description = "Proxy Port", value= "8080")
private static final String PROXY_PORT = "proxy.port";
我得到了port
属性的值如下:
..
...
properties = context.getProperties();
String port = properties.get(PROXY_PORT).toString();
...
port
在这种情况下会导致8080
。现在我想将这个String转换为Integer。我试过如下:
int portInt = Integer.parseInt(port);
int portInt2 = Integer.getInteger(port);
两个结果无效:(
我做了什么拨错
'port'有价值吗? – ItachiUchiha
int如何为null –
把'System.out.println(“**”+ port +“**”);'int portInt = Integer.parseInt(port);'告诉我们输出。 – StephaneM