Question

how can I escape " in NVelocity ?

e.g. test.message = "136# 1/4" Test Test Test"

if I do <input type="text" id="Test.Description" value="$test.message"/>

it displays : 136# 1/4

if I do <input type="text" id="Test.Description" value=$test.message/>

it displays : 136

if I do <input type="text" id="Test.Description" value='$test.message'/>

it displays : 136# 1/4" Test Test Test but it escapes '

how can I display 136# 1/4" Test Test Test without escaping anything ?

Était-ce utile?

La solution

nVelocity, at this time, has no built-in facility for HTML-encoding it's variables (there has been some talk about adding it in a future version)

In the meantime, in your controller, you'll just need to do:

test.message = HttpUtility.HtmlEncode(test.message);

or

test.message = test.message.Replace("\"", "&quot;");
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top