zoukankan      html  css  js  c++  java
  • nginx设置安全策略后,部分图片无法显示问题

    在nginx里增加

     add_header X-Content-Type-Options nosniff;
     add_header X-XSS-Protection "1; mode=block";    
     add_header X-Frame-Options "SAMEORIGIN";
    

     来处理安全问题时,发现网站有些图片无法在部分ie下正常访问。

    通过排查发现,

    有些ie对于通过io方式形成的图片,无法正常显示。原因:部分ie在解析页面上的图片时,若不指定页面的Content-Type,则不会显示。

    解决方案:在图片对外输出的outputStream时,增加

    if("jpg".equalsIgnoreCase(attachmentBean.getAttachextname()) || "jpeg".equalsIgnoreCase(attachmentBean.getAttachextname())){
    	response.addHeader("Content-Type", MediaType.IMAGE_JPEG_VALUE);
    }else if("png".equalsIgnoreCase(attachmentBean.getAttachextname())){
    	response.addHeader("Content-Type", MediaType.IMAGE_PNG_VALUE);
    }else if("gif".equalsIgnoreCase(attachmentBean.getAttachextname())){
    	response.addHeader("Content-Type", MediaType.IMAGE_GIF_VALUE);
    }
  • 相关阅读:
    爬弹幕
    写了这么多行就给我30,呜呜呜
    ticket
    yield求平均数
    协程原理
    爬取一类字二类字的信息和笔顺gif图片
    关于CRF的相关阅读
    embedding size与vocabulary size之间的关系: e = v**0.25
    pandas多个值取数
    转 pandas pivot
  • 原文地址:https://www.cnblogs.com/pigga/p/10098214.html
Copyright © 2011-2022 走看看