【问题标题】:java.io.IOException: Server returned HTTP response code: 401 authenticationjava.io.IOException:服务器返回 HTTP 响应代码:401 身份验证
【发布时间】:2014-11-06 10:36:44
【问题描述】:

当我使用以下代码未经身份验证显示图像时,出现 401 错误.. 如何解决这个错误?

<%
Authenticator.setDefault(new Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication(Constant.USER, Constant.PASSWORD.toCharArray());
    }
});
    String url=request.getAttribute("url").toString();

<img alt="" src="<%=url%>" />

我也尝试了以下链接,但询问我有关登录凭据的信息

http://techtipsjava.blogspot.in/2014/04/securing-restful-apis-with-http-basic.html http://www.xyzws.com/javafaq/how-to-add-basic-authentication-into-httpurlconnection/140

如何在没有登录凭据的情况下显示图像??? 谢谢

【问题讨论】:

    标签: java liferay liferay-6 alfresco


    【解决方案1】:

    添加 2 张票并没有太大帮助。如果您有一张 Alfresco 票证(可能您会使用 Alfresco & Liferay 的 SSO),那么您可以在 url 中添加票证以检索内容。

    看看wiki 和这个 StackOverlow 问题:Access file/content directly from Alfresco without log in

    【讨论】:

      猜你喜欢
      • 2012-07-02
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 2013-09-12
      • 1970-01-01
      • 1970-01-01
      • 2011-04-21
      • 1970-01-01
      相关资源
      最近更新 更多