Jspx 文件和条件注释
我想使用 Spring 和 .jspx 网页创建一个 Web 应用程序。
我的问题是如何在 jspx 中添加 IE 的条件注释?他们似乎没有被解释。
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
我还希望我的网页符合 HTML5 标准。
我尝试了一些方法,但在 IE9 中遇到不兼容问题(似乎无法识别标题和部分)。
编辑:
这是我的 head 标签
<meta content="text/html" charset="UTF-8" http-equiv="content-type" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<!--[if lte IE 9]>
<link rel="stylesheet" type="text/css" href="css/style_IE8.css" />
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
但是,如果我在 IE9 下查看源代码,我看不到 html5shiv 和我的辅助 css 的链接。
I'd like to create a web application using Spring and .jspx web pages.
My question is how can I put conditional commentaries for IE in jspx? They seem to be not interpreted.
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
Also I would like my web pages to be HTML5 compliants.
I've tried some methods but I got incompatibilty issues in IE9 (seems to not recognize header and section).
Edit:
Here is my head tag
<meta content="text/html" charset="UTF-8" http-equiv="content-type" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<!--[if lte IE 9]>
<link rel="stylesheet" type="text/css" href="css/style_IE8.css" />
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
But, if I look at the source under IE9 I don't see the links to html5shiv and my secondary css.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据 JSP 2.0 规范第 1.5.2 节,jsp 文档中的注释将被忽略:
第 6.2.2 节显示了一个使用
jsp:text
和 CDATA 部分的示例,可以根据您的用例进行调整,请尝试以下代码是否有效:According to the JSP 2.0 specification, section 1.5.2, comments in jsp documents are ignored:
Section 6.2.2 shows an example using
jsp:text
and CDATA sections which could be adapted to your usecase, please try if the following code works:经过大量的尝试,我发现使用 ASCII 代码作为注释符号在 .jspx 页面上效果非常好。试试这段代码:
After a vast quantity of attempts, I found that using ASCII codes for the comment symbols worked very nicely on .jspx pages. Try this bit of code:
对于 HTML 5 兼容性,使用 htmlshiv 导入是正确的。确保 head 标签内有条件导入。这与jstl无关。
For HTML 5 compatibility using the htmlshiv imports are correct. Make sure you have the conditional imports inside the head tags. This has nothing to do with jstl.
好吧,如果你查看生成的 HTML,你会意识到,jstl 会转义条件注释中的内容,因此它不起作用:
所以 Abhi,你需要告诉 jstl 保留条件部分,告诉它不要不解析它。 jstl 不会仅仅因为你把它放在 .
Well, if you view the generated HTML, you will realize, that jstl will escape the stuff out in the conditional comment, so it will not work:
So Abhi, you need to tell jstl to leave the conditional part alone, tell it to don't parse it. Jstl will not ignore it, just because you've put it in the .