我想要打包含xml結構的頁面。對於我正在使用此代碼CQ5中從存儲庫訪問頁面時的授權問題。
@Reference
private SlingRepository repository;
adminSession = repository.loginAdministrative(repository.getDefaultWorkspace());
String pageUrl = "http://localhost:4504"+page+".abc.htm";
conn = (HttpURLConnection)new URL(pageUrl).openConnection();
conn.setRequestProperty("Accept-Charset", charset);
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401"); // Do as if you'rusing Firefox 3.6.3
urlResponse = new BufferedInputStream(conn.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(urlResponse));
雖然accesing我得到這個問題
org.apache.sling.auth.core.impl.SlingAuthenticator getAnonymousResolver: `Anonymous access not allowed by configuration - requesting credentials`
我登錄的管理員,在每當我直接打這個urlfrom瀏覽器的頁面它正在工作正常bt而訪問它thriugh我的代碼我得到這個錯誤。
有什麼建議嗎?
您嘗試在同一個cq實例上訪問的頁面是否?如果是這樣,你爲什麼要做一個http請求?您可以通過[ResourceResolverFactory](https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/org/apache/sling/api/resource/ResourceResolverFactory)訪問存儲庫。 HTML),或者如果您真的需要執行 – d33t