2012-08-09 51 views
0

当创建一个Webservice,我可以以某种方式使用静态字符串变量?静态变量的Webservice声明不可能?

@WebService(
     portName = Util.PORT, 
     serviceName = Util.SERVICE, 
     targetNamespace = ..., 
     endpointInterface = ...) 
public class MyWsClass implements WsInterface 

结果:

The value for annotation attribute WebService.portName must be a constant expression 

所以我不能用静态瓦尔?

+0

你是怎么定义Util.PORT的? – JamesB 2012-08-09 21:10:29

+1

可能的重复[如何从一个常量的java提供值的注释](http://stackoverflow.com/questions/2065937/how-to-supply-value-to-an-annotation-from-a-constant- java) – Keppil 2012-08-09 21:10:47

回答