2014-11-06 125 views
0

當我使用下面的代碼顯示圖像沒有身份驗證,然後得到401錯誤.. 如何解決這個錯誤?java.io.IOException:服務器返回的HTTP響應代碼: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

我怎樣才能顯示圖像,而不登錄證書??? 謝謝

回答

相關問題