CodeBlue
CodeBlue

Reputation: 15389

<c:out/> single quote vs double quote. What is the difference?

What is the difference between

<c:out value='${expression.value}'/>

and

<c:out value="${expression.value}"/>

The first uses single quotes around ${expression.value} and the second uses double quotes.

Upvotes: 1

Views: 1413

Answers (2)

Mark Thomas
Mark Thomas

Reputation: 16625

You are free to use single quotes or double quotes. The only difference is how you then have to escape quotes used within the values. For example, if you wanted to use a value of don't then it would make more sense to use double quotes "don't" rather than single quotes 'don\'t' as with single quotes you'd have to escape the single quote within the value.

Upvotes: 3

Sionnach733
Sionnach733

Reputation: 4736

There is no difference, either is fine. the reason both are valid is so that " or ' can be used inside the expression. In that case you would use the other one to contain the expression. javascript and html also follow this convention.

example:

<c:out value='${expression.getValue("example")}'/>

Upvotes: 5

Related Questions