Path to WebContentFile in Spring
I'm using Spring 3 and would like to get the path to a folder 开发者_高级运维I have created under the WebContent folder. I want to create a File instance there.
A real path to the file under webapp root can be obtained using ServletContext.getRealPath().
Note that this method may return null if the concept of real path has no sense in your deployment configuration (for example, application is deployed as an unpacked .war), in this case you can't create a file there.
An instance of ServletContext in Spring can be autowired.
加载中,请稍侯......
精彩评论