Spring MVC : read file from src/main/resources

前端 未结 5 1586
梦谈多话
梦谈多话 2020-12-03 06:30

I have a maven Spring project, there is xml file inside src/main/resources/xyz.xml. How can I read it inside spring MVC controller.

I am us

5条回答
  •  爱一瞬间的悲伤
    2020-12-03 07:07

    For spring based application you can take advantage of ResourceUtils class.

    File file = ResourceUtils.getFile("classpath:xyz.xml")
    

提交回复
热议问题