JavaScript友好的替代品'角色可用吗?
在我的Xpage上,我设置了一个JavaScript变量onload:
var custName = '#{javascript: matterBean.getMatter().getCustomer().getCustName();}';
我用来替换Bootstrap对话框标题的此变量。
我注意到具有“字符”中的名称打破了代码。
我可以用
var custName =“#{javascript:MatterBean.getMatter()。getCustomer()。getCustName();}”;
但是,如果名称包含“角色。
是否有其他替代品,这样的后端代码(Java)可以返回javascript友好的替换'角色?
on my xpage I set a javascript variable onload:
var custName = '#{javascript: matterBean.getMatter().getCustomer().getCustName();}';
this variable I use to replace later the title of a bootstrap dialog.
I notice names with the ' character in it break the code.
I could replace it with
var custName = "#{javascript: matterBean.getMatter().getCustomer().getCustName();}";
but then this would break if the name contains the " character.
Is there an alternative, a javascript friendly replacement so the back-end code (java) could return a javascript friendly replacement for the ' character?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用Apache Commons Stringscapeutils逃脱字符串。例子:
You can use Apache Commons StringEscapeUtils for escaping the string. Example: