How to comment in jspx page

你说的曾经没有我的故事 提交于 2019-12-10 15:44:36

问题


How to comment the code in jspx page? I have tried several methods,

<!--  -->
<%-- -->

but it doesn't not work!

So I have to:

<c:if test="${false}">code</c:if>,

it is really urgly, Is there any other ways? Any help is appreciated!


回答1:


JSP.1.5.2 Comments in JSP Documents

Comments in JSP documents use the XML syntax... The body of the content is ignored completely. [3]

CDATA sections may occur anywhere character data may occur; they are used to escape blocks of text containing characters which would otherwise be recognized as markup. [4]

  1. java.sun.com/products/jsp/syntax/2.0/syntaxref203.html#1004313
  2. java.net/jira/browse/JSP_SPEC_PUBLIC-105
  3. http://jsp.java.net/spec/jsp-2_1-fr-spec.pdf
  4. http://www.w3.org/TR/REC-xml/#sec-cdata-sect

    <![CDATA[<!-- comment -->]]>




回答2:


Just use <!-- comment --> for comments. JSPX file uses XML syntax so that's the reason XML style comment work here.

Also read article Creating a JSP Document for understanding the difference between JSP standard syntax and XML syntax




回答3:


You were close with one of your attempts, JSP comments look like below:

<%-- some commented out stuff --%>



回答4:


Have you tried XML IGNORE?

<![IGNORE[
  <!-- commented out XML -->
]]>

Change IGNORE to INCLUDE when you want it back.




回答5:


There are 2 kinds of comments: JSP comments and HTML comments.

  • JSP commet: <%-- comment text --%>

  • HTML/XML comment: <!-- comment -->

JSP comments are not exported to HTML and are ignored by the JSP Engine.

HTML comments are exported to HTML because they are valid HTML tags.



来源:https://stackoverflow.com/questions/3022015/how-to-comment-in-jspx-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!