unterminatedstringliteral翻译,nutritionists翻译
推荐文章
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方法转换了"" ,""。
然后页面接收了一下:
[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()方法时需要注意,要用一个值去接收才能获取到转换后的字符串。看replaceAll()的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内容就会变了。。。怎么运行都不对。。。。(╯‵□′)╯︵┻━┻
妈蛋真是被自己蠢哭了。。。QAQ
---------------------------------------------------------------------------------------------------------------------------------------------------------------
发现问题是因为换行识别不了,不是一个完整的字符串,因此需要将/r/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("\"", "\\"+"\""); //转换引号
temp = temp.replaceAll("\r\n", "br "); //转换换行
OK....终于能正常显示了。
数据库里是这样的:
unterminated string是什么意思
unterminated string
未结束的字符串
双语例句
1
Unterminated String in tag closing quote expected
标记中的字符串未结束期望提供右引号
2
Unterminated string or character constant
未终结的串或字符常量
百度编辑器unterminated string literal怎么解决
nterminated string literal提示,我百度了一下,发现是js中单引号、双引号、换行、回车 都是违反json规范,下面我们来处理一下。
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是什么意思?
未结束的字符串常量。
看看字符串里面是不是有转义字符,或者少了引号