Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS 因 Mime 类型不匹配而被忽略 引发的问题 #71

Closed
icevb6 opened this issue Jun 8, 2016 · 4 comments
Closed

CSS 因 Mime 类型不匹配而被忽略 引发的问题 #71

icevb6 opened this issue Jun 8, 2016 · 4 comments
Labels

Comments

@icevb6
Copy link

icevb6 commented Jun 8, 2016

ie9 错误:
SEC7113: CSS 因 Mime 类型不匹配而被忽略
main.min.css?ver=0.1.3

chrome:
Resource interpreted as Stylesheet but transferred with MIME type text/plain: "http://localhost:8678/java-china/assets/styles/main.min.css?ver=0.1.3".

百度了一下,此问题,应该需要在response的按照 后缀名 (.css) 设置 contextType的 text/css

研究了一下源码:

DispatcherHandler 中 print 的时候设置一下?是否正确?还需要作者考虑一下。

方案:
可以根据web.xml里的配置来进行设置。

css text/css

不知道能否修正这个问题,如果加载远程的css (配置成您官方的https://java-china.org/assets/styles/main.min.css 不会出现问题)是没有问题的,但放到本地加载会出现此问题。

谢谢!!!!!

@icevb6
Copy link
Author

icevb6 commented Nov 29, 2016

请问这个问题怎么解决?

@hellokaton
Copy link
Member

这个没有问题啊

@icevb6
Copy link
Author

icevb6 commented Nov 29, 2016

应该是一个bug,改了一下源码,可以解决此问题。
DispatcherHandler 90行处添加代码:
if (uri.matches(".+(css)$")) {//|js|ico|swf
response.raw().setContentType("text/css;charset=utf-8");
} else if (uri.matches(".+(js)$")) {
response.raw().setContentType("text/javascript;charset=utf-8");
} else if (uri.matches(".+(ico)$")) {
response.raw().setContentType("image/x-icon;charset=utf-8");
} else if (uri.matches(".+(swf)$")) {
response.raw().setContentType("application/x-shockwave-flash;charset=utf-8");
} else if (uri.matches(".+(jpe)$") || uri.matches(".+(jpeg)$") || uri.matches(".+(jpg)$")) {
response.raw().setContentType("image/jpeg;charset=utf-8");
} else if (uri.matches(".+(png)$")) {
response.raw().setContentType("image/png;charset=utf-8");
}

@icevb6
Copy link
Author

icevb6 commented Nov 29, 2016

ie9以上出现无法加载,google浏览器上出现warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants