开发者

Getting a Web Accessible Directory in Spring-MVC/Java

Simple problem, I need to write a sitemap to my web root directory so that it is accessible as so:

http://mysite.com/sitemap.xml

I want the code to look like:

File f = n开发者_运维技巧ew File( someMethodToGetWebRootDirectory() );

But I don't know what should be in that method


Will something along the lines of:

File classesDir = new File(YourServlet.class.getProtectionDomain()
    .getCodeSource().getLocation().getPath().replaceAll('/', File.separator));
File rootDir = classesDir.getParentFile().getParentFile();

work?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜