How to access a file under WEB-INF folder in java class

后端 未结 4 814
终归单人心
终归单人心 2020-12-01 16:35

I have a plain java class in a web application and want to read a configuration file under WEB-INF folder. I know the way to access the file if its in the class

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 17:03

    You can get the absolute path of servlet using getRealPath() method of ServletContext and then append WEB-INF to the path you get. I think this is very basic there may be some other answers as well.

提交回复
热议问题