Reputation: 291
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!
Upvotes: 4
Views: 6226
Reputation: 3
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.
Upvotes: 0
Reputation: 41
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]
http://www.w3.org/TR/REC-xml/#sec-cdata-sect
<![CDATA[<!-- comment -->]]>
Upvotes: 4
Reputation: 2205
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
Upvotes: 3
Reputation: 75496
Have you tried XML IGNORE?
<![IGNORE[
<!-- commented out XML -->
]]>
Change IGNORE to INCLUDE when you want it back.
Upvotes: 0
Reputation: 26128
You were close with one of your attempts, JSP comments look like below:
<%-- some commented out stuff --%>
Upvotes: 0