【问题标题】:Mismatch of opening and closing quote of href while dealing with jsp session value处理jsp会话值时href的开始和结束引用不匹配
【发布时间】:2015-07-01 11:31:03
【问题描述】:

我正在开发一个 jsp 应用程序。我的session 中有一个User 对象。
从 jsp 我可以成功访问以下值 -

userType = ${USER.type};
editPermission = ${USER.hasPermission['editPermission'];  //case 1.

这里hasPermissionMap<String, Boolean>。在 案例 1 中,它返回真/假。但是当我在<a> 中使用它时,它不能正常工作。 href 属性引号 ('') 似乎与 'editPermission' 引号冲突。请问谁能帮我解决这个问题?

<a href="#tab" onclick="window.location.href='.../home.do?tbNam=all&userType=${USER.type}&editPermission=${USER.hasPermission['editPermission']}';">All</a>

提前致谢。

【问题讨论】:

  • 我认为您在 "${USER.hasPermission['editPermission']' 之后缺少了 '}' 右括号。检查
  • @Ramkumar,感谢您的发现。这是我已经修复的错别字。但在我的代码中有'}'
  • 您可以使用转义序列“\”。请检查这个 onclick="window.location.href=\".../home.do?tbNam=all&userType=${USER.type}&editPermission=${USER.hasPermission['editPermission']}\";"

标签: javascript jsp anchor href


【解决方案1】:

变量不在此上下文中计算。

这样做

<a href="#tab" onclick="window.location.href='.../home.do?tbNam=all&userType=' + ${USER.type} + '&editPermission=' + ${USER.hasPermission['editPermission']} + ';'>All</a>

【讨论】:

    猜你喜欢
    • 2015-06-28
    • 1970-01-01
    • 1970-01-01
    • 2015-03-02
    • 2013-05-08
    • 1970-01-01
    • 1970-01-01
    • 2021-04-14
    • 1970-01-01
    相关资源
    最近更新 更多