admin管理员组文章数量:1418056
The .war is served from GlassFish v3. I am trying to include a javascript file from my jspx.
<script type="text/javascript" src="/base/interface/Service.js"></script>
I get the following in my http response
<script src="/base/interface/Service.js" type="text/javascript" />
The problem is that it should include the </script>
tag. I believe this is why it works on Chrome, but not on Firefox or IE. Any idea how to force <script></script>
Update: Not sure if any of this is pertinent, but here is the beginning of my jspx file
<jsp:root version="2.0"
xmlns:jsp=""
xmlns:c=""
xmlns:fmt=""
xmlns:form=""
xmlns:spring=""
xmlns="">
<jsp:output doctype-root-element="html"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system=".dtd"/>
<jsp:directive.page contentType="text/html" pageEncoding="UTF-8"/>
...
The .war is served from GlassFish v3. I am trying to include a javascript file from my jspx.
<script type="text/javascript" src="/base/interface/Service.js"></script>
I get the following in my http response
<script src="/base/interface/Service.js" type="text/javascript" />
The problem is that it should include the </script>
tag. I believe this is why it works on Chrome, but not on Firefox or IE. Any idea how to force <script></script>
Update: Not sure if any of this is pertinent, but here is the beginning of my jspx file
<jsp:root version="2.0"
xmlns:jsp="http://java.sun./JSP/Page"
xmlns:c="http://java.sun./jsp/jstl/core"
xmlns:fmt="http://java.sun./jsp/jstl/fmt"
xmlns:form="http://www.springframework/tags/form"
xmlns:spring="http://www.springframework/tags"
xmlns="http://www.w3/1999/xhtml">
<jsp:output doctype-root-element="html"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<jsp:directive.page contentType="text/html" pageEncoding="UTF-8"/>
...
Share
Improve this question
asked Jan 13, 2010 at 17:06
Matthew SowdersMatthew Sowders
1,7002 gold badges19 silver badges33 bronze badges
4 Answers
Reset to default 4I used <script ...><jsp:text> </jsp:text></script>
and that retained the closing tag. I think this is ugly, so if anyone has a better answer I would definitely be interested.
Unfortunately, jspx is known to "minimize" empty elements. One way to prevent the minimization without adding a space to the rendered HTML is to insert a ment. For example:
<script ...><!-- keep open/close tags --></script>
It is still ugly, though.
A potentially cleaner solution would be to create a custom taglib that outputs correct HTML, e.g.:
<m:htmlScript type="text/javascript" src="/js/jquery-1.4.4.min.js"/>
producing:
<script type="text/javascript" src="/js/jquery-1.4.4.min.js">
Another alternative would be to encapsulate the tag in CDATA:
<![CDATA[<script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>]]>
I covered this topic in more detail here: How to produce valid HTML with JSPX? (not XHTML)
Yet another ugly solution:
<tag>${null}</tag>
本文标签: javascriptjspx script element on GlassFish v3Stack Overflow
版权声明:本文标题:javascript - jspx script element on GlassFish v3 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745251292a2649836.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论