【发布时间】:2014-02-02 00:37:18
【问题描述】:
根据ResourceResolver接口:
http://dev.day.com/docs/en/cq/current/javadoc/org/apache/sling/api/resource/ResourceResolver.html
有三种方法可以解析资源的路径或请求:
Resource resolve(HttpServletRequest request)已弃用。从 2.0.4 开始,请改用 resolve(HttpServletRequest, String)。Resource resolve(HttpServletRequest request, String absPath)从给定的 absPath 中解析资源,可选地 HttpServletRequest 考虑在内,比如 Host 请求头的值。Resource resolve(String absPath)从给定的绝对路径解析资源。
但如果我有一个随机给定的 URL 字符串(例如http://www.mycompany.com/whatever.html),我如何以编程方式找出给定 URL 的相应资源?
【问题讨论】:
-
您找到了正确的 API。您的问题是如何在 JSP/Servlet 中使用它?
-
问题是该API没有接受URL字符串,只有absPath字符串。