using classpath: in spring

前端 未结 2 1681
感情败类
感情败类 2020-12-05 00:24

I have two questions regarding classpath: option in spring :-

1) Does classpath: search for resource relative to the document in which it i

2条回答
  •  佛祖请我去吃肉
    2020-12-05 01:00

    Does classpath: search for resource relative to the document in which it is specified(in case of web applications)?

    No, classpath: is always relative to the classpath root. If you put a / at the start of the path, it is silently removed.

    Is it more fast to search if i give direct location of resource instead e.g. classpath:/WEB-INF/classes/myfolder/myfile.txt

    No, that won't work at all. The classpath root contains /WEB-INF/classes, so the path should be relative to that.

    Don't confuse classpath: paths with file paths, they have no relation to each other.

提交回复
热议问题