当前位置: 代码迷 >> Java Web开发 >> <bean:write> 内容含有引号如何避免?50积分~
  详细解决方案

<bean:write> 内容含有引号如何避免?50积分~

热度:84   发布时间:2016-04-17 10:42:51.0
<bean:write> 内容含有引号如何处理?50积分~~
JScript code
<script language="JavaScript">function initOption(type) {  document.forms[0].myOp.options.length = 0;  <logic:iterate id="myOpNumList" indexId="index" name="SiteForm" property="myOpNumList" type="com.common.vo.basic.myOpForm">      document.forms[0].myOp.options.add(new Option("<bean:write name='myOpNumList' property='label' filter='false'/>","<bean:write name='myOpNumList' property='ID'/>"));  </logic:iterate>}


这里<bean:write name='myOpNumList' property='label' filter='false'/>取得的label内容中有双引号,会导致页面出错,该如何处理?这里这能在页面处理,不能在后台直接替换。
谢谢~~ 急啊~~
小弟新手啊

------解决方案--------------------
用转义符转义下
------解决方案--------------------
var str = "<bean:write name='myOpNumList' property='label' filter='false'/>";

while (str.indexOf('"') >= 0){
str = str.replace('"', "");
}

------解决方案--------------------
在每个“前加个\
------解决方案--------------------
var str = "<bean:write name='myOpNumList' property='label' filter='false'/>";

while (str.indexOf(') >= 0){
str = str.replace(', "");
}
直接前台处理也行
------解决方案--------------------
个人觉得到后台处理还好点。
------解决方案--------------------
"变成 \" 不行吗?
  相关解决方案