Spring MVC : read file from src/main/resources

前端 未结 5 1603
梦谈多话
梦谈多话 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 06:59

    Here is one way of loading classpath resources.

    Resource resource = applicationContext.getResource("classpath:xyz.xml");
    InputStream is = resource.getInputStream();
    

提交回复
热议问题