Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 添加X-Content-Type-Options无嗅探_Java_Jsp_Spring Security_Http Headers_Security - Fatal编程技术网

Java 添加X-Content-Type-Options无嗅探

Java 添加X-Content-Type-Options无嗅探,java,jsp,spring-security,http-headers,security,Java,Jsp,Spring Security,Http Headers,Security,我目前正在尝试为我的java应用程序实现更多的安全措施,并且遇到了使用x-content-type-options no-sniff的建议。在我的搜索中,我找不到任何实现此功能的方法。非常感谢您的帮助。假设您正在使用Spring,您可以尝试- <mvc:annotation-driven/> <mvc:interceptors> <bean id="webContentInterceptor" class="org.springfram

我目前正在尝试为我的java应用程序实现更多的安全措施,并且遇到了使用x-content-type-options no-sniff的建议。在我的搜索中,我找不到任何实现此功能的方法。非常感谢您的帮助。

假设您正在使用Spring,您可以尝试-

<mvc:annotation-driven/>
<mvc:interceptors>
    <bean id="webContentInterceptor" 
          class="org.springframework.web.servlet.mvc.WebContentInterceptor">
        <property name="X-Content-Type-Options" value="nosniff"/>
    </bean>
</mvc:interceptors>


如果这个问题看起来很愚蠢,我提前道歉。但是这个实现在Tomcat中有效吗?如果是这样,它需要在应用程序中的什么位置?@DD84-它应该在Tomcat中工作。试着把它放在/WEB-INF/spring/webmvc-config.xml中。如果您正在使用jsp,您可以把它放在jsp中。。或者,您可以扩展默认筛选器并附加此标头,然后继续筛选器链。如何使用
注释
执行此操作?