我在用个OA短信接口,他给了个例子://他们的接口
public interface SmsService {
    public boolean sendSMS(String smsId,String number,String msg);
}
//例子
public class TestService implements SmsService{
public boolean sendSMS(String smsId,String number,String msg){
System.out.println("接受人:"+number);
System.out.println("测试短信:"+msg);
return true;
}
}
问题是我不知道这个TestService 的全局函数应该写在哪啊?

解决方案 »

  1.   

    java应该不支持全局函数吧,如果你想用的话,写成Static的方法吧
      

  2.   


    application是哪?任意一个页面中吗?
      

  3.   

    TestService 就是你写的工具类 你在jsp里直接调用他的方法
      

  4.   


    我原来也是这么想的,但是他这个接口还需要配置sms.xml<module id="sms" version="1.0.0">
        <service-point id="smssender" interface="weaver.sms.SmsService">
            <invoke-factory>
    <construct class="weaver.sms.TestService">
    //如果之前不是用全局函数,那么这个construct class是什么回事?
                </construct>
            </invoke-factory>
        </service-point>   
    </module>
      

  5.   

    weaver.sms.TestService
    表示
    \weaver\sms\TestService.CLASS 也不知道对不对……我写成这样看看
      

  6.   

    我勒个擦,ecology发短信啊,配置不一样,问问给你的人呗。
      

  7.   

    application就和session一样 不过范围不一样 session在当前浏览器都存在可是关闭浏览器则会消失
    而application是存在服务器中的 除非你的服务器重启了否则application会一直存在
    当然前提是你没有吧application给remove掉啦
      

  8.   

    所以全局的就用application啦
    变量保存在配置文件中也可以 恩