开发者

loading multy-line text from database into javascript variable error

I am trying to load multi-line text from a MySQL database in开发者_C百科to a JavaScript variable, but it doesn't work.

I get the text from the database, then add the text to a spring model as its attribute "mytext".

In a jsp file, I want to retrieve the text, so I have code like this:

 var text = '<c:out value="${mytext}"/>'; //multy-line text
 alert(text);

The above code fails, and the function alert() would not be called.

If the text from the database is single-line, it goes well.

How can this be fixed in script code?


You can use a character sequence to join the multiline text into one line (server side) and then split the text using javascript using the same character sequence.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜