문제

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 ?

도움이 되었습니까?

해결책

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;");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top