开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜