Get Web App root from Spring Controller

后端 未结 3 2001
一整个雨季
一整个雨季 2020-12-14 22:07

I am trying to write an uploaded multipart file to the filesystem. I have a directory called audio which sits in the root of my web application (not inside WEB-INF, but bes

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-14 22:32

    I thought getting a ServletContext() then using realPath() may work, but I don't have a reference to ServletContext

    Yes you do. See HttpServletRequest.getSession().getServletContext()

提交回复
热议问题