Difference between Tomcat's extraResourcePaths and aliases to access an external directory

前端 未结 2 1254
借酒劲吻你
借酒劲吻你 2021-01-06 17:35

Simple question: In Tomcat7, what\'s the difference between using extraResourcePaths and aliases to access an directory outside the application?

I can use either of

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-06 18:05

    After investigating further, I found this difference.

    The results of this Java code is different. I still don't know why.

    String path = getServletContext().getRealPath("/images");
    

    Using extraResourcePaths, path is below, which is a folder under where Eclipse explodes my web app and not a valid directory.

    C:\Projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\Eclipse_Project\images
    

    Using aliases, path is below and is what I actually need.

    D:\path\to\images
    

    Now if someone could actually explain this. :-)

提交回复
热议问题