Loading properties file in GWT on Tomcat

后端 未结 2 1622
猫巷女王i
猫巷女王i 2021-01-23 15:58

I know there are lots of similar questions out there, but none of which that helped. We have a GWT application running on a tomcat server, which is loading a properties file for

2条回答
  •  旧巷少年郎
    2021-01-23 16:27

    Wo do nearly the same here with "Packager.class" as a class in the same directory; The idea here is to find the path via the class path, which works on tomcat:

    final ClassPool pool = ClassPool.getDefault( );
    final Class baseClass = Packager.class;
    pool.insertClassPath( new ClassClassPath( baseClass ) );
    
    final URL url = pool.find( baseClass.getName( ) );
    
    String pathToBaseClass = url.toURI( ).getPath( );
    String baseDir = pathToBaseClass.substring( 0, pathToBaseClass.indexOf( "com" ) - 1 );
    

提交回复
热议问题