请大伙帮下忙`
jsp如何传递带引号的参数`
window.location.href="update.jsp?updateid="+updateid
updateid的从数据库中取出的字符串 并且有些带有引号,
比如 "001"231
"002"232
在update.jsp页面上
String updateid=request.getParameter("updateid");
<textarea rows="4" name="descn" id="descn" cols="39" value="<%=updateid%>"></textarea>
这个value 怎么写才能得到正确字符串啊.
jsp如何传递带引号的参数`
window.location.href="update.jsp?updateid="+updateid
updateid的从数据库中取出的字符串 并且有些带有引号,
比如 "001"231
"002"232
在update.jsp页面上
String updateid=request.getParameter("updateid");
<textarea rows="4" name="descn" id="descn" cols="39" value="<%=updateid%>"></textarea>
这个value 怎么写才能得到正确字符串啊.
单引号就好了!
我做实验
<html>
<head></head>
<script type="text/javascript">
function my(){
var fuyou='"123"001';
window.location.href="fuyou.jsp?fuyou="+fuyou;
}
</script>
<body>
<input type="button" onClick="my()" value="ss">
</body>
</html> <html>
<head></head><body>
<%
String strs= request.getParameter("fuyou");out.println(strs);//打印出"123"001%>
</body>
<input type="text" value='<%=strs%>'><!-- 显示"123"001-->
</html>
String s = "".replace('"', '"');
window.location.href="update.jsp?updateid="+〈%=java.net.URLEncoder.encode(updateid,"UTF-8");%〉 在update.jsp页面上
<%
String updateid=request.getParameter("updateid");
updateid=java.net.URLEncoder.encode(updateid,"UTF-8");//再次编码
updateid="<script type=\'text/javascript\'>var s=encodeURIComponent("+updateid+")\;
document.getElementsByTagName(\"textarea\")[0].value=s\;</script>";//js解码
%>
把赋值转移到上面的脚本中,下面就不用了
<textarea rows="4" name="descn" id="descn" cols="39" value=" "> </textarea>