SpringMVC Resource interpreted as Script but transferred with MIME type application/octet-stream:
来源:互联网 发布:iphone4s实用软件 编辑:程序博客网 时间:2024/05/29 13:25
Spring MVC 页面加载 js文件的时候,Chrome 浏览器的console提示
意思是说,本来浏览器请求的是Script文件,即js文件,但是服务器返回的是文本文件
Resource interpreted as Script but transferred with MIME type application/octet-stream:
具体截图
尽管不影响功能,但是有这个提示总感觉别扭。
然后还有一个规律,就是第一次访问的时候会提示,刷新页面也就是第二次访问这个提示就没有了。清除浏览器缓存访问则再次出现。
最后比对了一个没有这个提示的项目,发现这个和SpringMVC 中对静态文件设置的代码段的位置有关。
mvc-servlet.xml
开始是如下(注意,“处理静态资源”这个注释下代码段的位置)
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:util="http://www.springframework.org/schema/util"xmlns:orm="http://www.springframework.org/schema/orm" xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsdhttp://www.springframework.org/schema/orm http://www.springframework.org/schema/orm/spring-orm-4.3.xsdhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"><!-- 处理静态资源 --><!-- <mvc:resources mapping="/resources/**" location="/resources/"/> --><mvc:resources mapping="/js/**" location="/js/"/><!-- 配置注解驱动 --><mvc:annotation-driven/><!-- 定义默认访问 --><mvc:view-controller path="/" view-name="forward:home"/><!-- 视图解析器注册bean -jsp视图解析 http://tool.oschina.net/apidocs/apidoc?api=Spring-3.1.1--><bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="contentType" value="text/html"/> <property name="prefix" value="/WEB-INF/views/"/><property name="suffix" value=".jsp"/></bean><!-- 扫描bean --><context:component-scan base-package="com.bestcxx.mavenstu.mvc.controller"/></beans>
之后改为如下(注意,“处理静态资源”这个注释下代码段的位置)
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:util="http://www.springframework.org/schema/util"xmlns:orm="http://www.springframework.org/schema/orm" xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsdhttp://www.springframework.org/schema/orm http://www.springframework.org/schema/orm/spring-orm-4.3.xsdhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"><!-- 配置注解驱动 --><mvc:annotation-driven/><!-- 定义默认访问 --><mvc:view-controller path="/" view-name="forward:home"/><!-- 视图解析器注册bean -jsp视图解析 http://tool.oschina.net/apidocs/apidoc?api=Spring-3.1.1--><bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="contentType" value="text/html"/> <property name="prefix" value="/WEB-INF/views/"/><property name="suffix" value=".jsp"/></bean><!-- 扫描bean --><context:component-scan base-package="com.bestcxx.mavenstu.mvc.controller"/><!-- 处理静态资源 --><!-- <mvc:resources mapping="/resources/**" location="/resources/"/> --><mvc:resources mapping="/js/**" location="/js/"/></beans>
就是,静态js文件的声明放到的底部浏览器就可以正常访问了,具体原因还是不得而知,但是这说明配置文件中是有先后顺序之分的。
0 0
- SpringMVC Resource interpreted as Script but transferred with MIME type application/octet-stream:
- Resource interpreted as Stylesheet but transferred with MIME type application/octet-stream
- 关于chrome Resource interpreted as Script but transferred with MIME type text/html的问题
- 关于chrome Resource interpreted as Script but transferred with MIME type text/html的问题
- golange 错误如下 Resource interpreted as Script but transferred with MIME type text
- Chrome 报 Resource interpreted as Script but transferred with MIME type text/plain 警告的解决办法
- Resource interpreted as Script but transferred with MIME type text/html
- 关于 Resource interpreted as Script but transferred with MIME type text/plain问题的处理
- Chrome 报 Resource interpreted as Script but transferred with MIME type text/plain 警告的解决办法
- 关于easyui Resource interpreted as Document but transferred with MIME type application/json
- Resource interpreted as Stylesheet but transferred with MIME type application/x-css
- Resource interpreted as Font but transferred with MIME type application/x-font-woff
- Resource interpreted as Document but transferred with MIME type application/json ...
- ThinkPHP Resource interpreted as Document but transferred with MIME type application/json 导致js无效
- Resource interpreted as Document but transferred with MIME type application/json:
- Resource interpreted as Stylesheet but transferred with MIME type text/html:以及Uncaught SyntaxError:
- Resource interpreted as Image but transferred with MIME type text/plain 警告解决方案
- Java过滤器引发的异常:Resource interpreted as Stylesheet but transferred with MIME type text/html
- android 步骤指示器实现
- Linux 下的一个全新的性能测量和调式诊断工具 Systemtap
- [POJ]3299-Humidex[初投稿]
- [Kotlin&Anko开发Android入门学习笔记]-01使用Kotlin创建Activity活动
- ArcGIS Engine程序开发之 IToolbarMenu.AddItem()函数中的参数
- SpringMVC Resource interpreted as Script but transferred with MIME type application/octet-stream:
- 数位dp入门详解
- 经典排序算法 – 插入排序Insertion sort
- Java面试题集
- [BZOJ2400]Spoj 839 Optimal Marks(最小割)
- <The Art of Readable Code> 笔记二 (上)
- hdoj 2089 不要62(数位dp入门模板)
- 经典排序算法 - 希尔排序Shell sort
- 选好的,选知名品牌