Jspx文件和条件注释 [英] Jspx files and conditional comments

查看:397
本文介绍了Jspx文件和条件注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Spring和.jspx网页创建一个web应用程序。



我的问题是如何将条件注释用于jspx中的IE?他们似乎没有解释。

 <! -  [if lt IE 9]> 
< link rel =stylesheettype =text / csshref =css / style.css/>
< script src =http://html5shiv.googlecode.com/svn/trunk/html5.js>< / script>
<![endif] - >

另外我想让我的网页成为HTML5 compliants。



我尝试了一些方法,但在IE9中遇到了不兼容问题(似乎无法识别标题和部分)。



编辑:



这是我的头标

 < meta content =text / html charset =UTF-8http-equiv =content-type/> 
< link rel =stylesheettype =text / csshref =css / style.css/>
<! - [if lte IE 9]>
< link rel =stylesheettype =text / csshref =css / style_IE8.css/>
< script src =http://html5shiv.googlecode.com/svn/trunk/html5.js>< / script>
<![endif] - >

但是,如果我查看IE9下的源代码,我看不到html5shiv和我的链接secondary CSS

解决方案

根据JSP 2.0规范,第1.5.2节,忽略jsp文档中的注释:


JSP文档中的注释使用XML语法,如下所示:

<! - comments ... - >



内容的主体完全被忽略。 JSP文档中的注释
可用于文档目的和注释
JSP页面的部分。

第6.2.2节展示了一个使用 jsp:text 和CDATA部分的例子,它可以适用于你的用例,请尝试下面的代码:

 < jsp:text><![CDATA [<! -  [if lte IE 9]>]]< ; / JSP:文本> 
...
< jsp:text><![CDATA [<![endif] - >]]>< / jsp:text>


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.

解决方案

According to the JSP 2.0 specification, section 1.5.2, comments in jsp documents are ignored:

Comments in JSP documents use the XML syntax, as follows:

<!-- comments ... ->

The body of the content is ignored completely. Comments in JSP documents may be used for documentation purposes and for "commenting out" portions of a JSP page.

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:

<jsp:text><![CDATA[<!--[if lte IE 9]>]]></jsp:text>
...
<jsp:text><![CDATA[<![endif]-->]]></jsp:text>

这篇关于Jspx文件和条件注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆