Import Java. Io. inputstream; Import Java. util. properties; /** * @ Author Guoxiang * */ Public Class Config { Private Static Config instance = Null ; Private Properties Properties = Null ; Private Config () {Init ();} Public Static Config getinstance (){ If (Instance = Null ) {Instance = New Config ();} Return Instance ;} /** * Initialize the configuration file */ Public Void Init (){ Try {Inputstream is = Config. Class . Getresourceasstream ("/config. properties" ); Properties = New Properties (); properties. Load (is );} Catch (Exception e ){ Throw New Runtimeexception ("failed to get properties! " );}} /** * Obtain the corresponding value based on the key value * @ Param Key * @ Return */ Public String getvalue (string key ){ Return Properties. getproperty (key );} /** * @ Return The properties */ Public Properties getproperties (){ Return Properties ;}} Private Static Final String config_path = "config. path" ; Private Static Properties Config = Null ; Static { Try {Config = Com. tianditu. util. config. getinstance (). getproperties ();} Catch (Exception e) {e. printstacktrace () ;}} strdirconfig = Config. getproperty (config_path );
Is the website put in the WEB-INF \ classes, not the website put in the bin
# Map urlsearchmap. url = Http:// ************* Config. Path = D:/ngis_config/