促銷活動

5U文學網(wǎng) > 實用文 > 活動方案 > 促銷活動 > unterminatedstringliteral翻譯,nutritionists翻譯

unterminatedstringliteral翻譯,nutritionists翻譯

| admin

unterminated string literal錯誤怎么解決

[html] view plain copy

select name="${item.name}" id="${item.id}" style="${item.styles}" class="commonInput longtext ${item.classes}"

option value="${item.value}"

/option

/select

因此在后臺用replaceAll方法轉(zhuǎn)換了"" ,""。

然后頁面接收了一下:

[javascript] view plain copy

script type="text/javascript"

var isModify = "${isModify}";

if(isModify == 1){

document.getElementById("textarea1").innerHTML = "${contentTemp}";

alert("success");

}

/script

然后在firebug里報錯鳥,unterminated string literal

Other...

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

在使用replaceAll()方法時需要注意,要用一個值去接收才能獲取到轉(zhuǎn)換后的字符串??磖eplaceAll()的API:

String java.lang.String.replace(CharSequence target,CharSequence replacement)

Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the string to the end, for example, replacing "aa" with "b" in the string "aaa" will result in "ba" rather than "ab".

Parameters:

target The sequence of char values to be replaced

replacement The replacement sequence of char values

Returns:

The resulting string

Throws:

我一開始直接

[java] view plain copy

content.replaceAll("", "").replaceAll("", "");

還以為直接這樣content內(nèi)容就會變了。。。怎么運行都不對。。。。(╯‵□′)╯︵┻━┻

媽蛋真是被自己蠢哭了。。。QAQ

---------------------------------------------------------------------------------------------------------------------------------------------------------------

發(fā)現(xiàn)問題是因為換行識別不了,不是一個完整的字符串,因此需要將/r/n轉(zhuǎn)換一下。

[java] view plain copy

@Override

protected String handleEdit(HttpServletRequest request,

HttpServletResponse response, Long objectId) throws Exception {

if(objectId != null ){

Element element = elementManager.getByObjectId(objectId);

String temp = element.getContent().replaceAll("", "").replaceAll("", "");

temp = temp.replace("\"", "\\"+"\"");

temp = temp.replaceAll("\r\n", "br ");

request.setAttribute("contentTemp", temp);

request.setAttribute("isModify", 1);

}

return super.handleEdit(request, response, objectId);

}

[java] view plain copy

temp = temp.replace("\"", "\\"+"\""); //轉(zhuǎn)換引號

temp = temp.replaceAll("\r\n", "br "); //轉(zhuǎn)換換行

OK....終于能正常顯示了。

數(shù)據(jù)庫里是這樣的:

unterminated string是什么意思

unterminated string

未結(jié)束的字符串

雙語例句

1

Unterminated String in tag closing quote expected

標記中的字符串未結(jié)束期望提供右引號

2

Unterminated string or character constant

未終結(jié)的串或字符常量

百度編輯器unterminated string literal怎么解決

nterminated string literal提示,我百度了一下,發(fā)現(xiàn)是js中單引號、雙引號、換行、回車 都是違反json規(guī)范,下面我們來處理一下。

template/bbs/post_run.htm

找到這段

var word_tpl = 'div class="pop_sensitive"\

div class="pop_top J_drag_handle"\

a href="#" class="pop_close J_close"關閉/a\

strong提示/strong\

/divdiv class="pop_cont"\

div class="not_content_mini" id="J_word_tip"/div\

/div\

div class="pop_bottom" id="J_word_bototm"/div\

/div',

改成

var word_tpl = 'div class="pop_sensitive"div class="pop_top J_drag_handle"a href="#" class="pop_close J_close"關閉/astrong提示/strong/divdiv class="pop_cont"div class="not_content_mini" id="J_word_tip"/div/div div class="pop_bottom" id="J_word_bototm"/div/div',

JSONParseError: Unterminated string literal是什么意思?

未結(jié)束的字符串常量。

看看字符串里面是不是有轉(zhuǎn)義字符,或者少了引號

223768