Java 添加X-Content-Type-Options无嗅探
我目前正在尝试为我的java应用程序实现更多的安全措施,并且遇到了使用x-content-type-options no-sniff的建议。在我的搜索中,我找不到任何实现此功能的方法。非常感谢您的帮助。假设您正在使用Spring,您可以尝试-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
<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中。。或者,您可以扩展默认筛选器并附加此标头,然后继续筛选器链。如何使用注释执行此操作?