【问题标题】:How to set response.sendRedirect to a particular tab on a jsp page如何将 response.sendRedirect 设置为 jsp 页面上的特定选项卡
【发布时间】:2018-04-09 09:03:22
【问题描述】:

我有一个名为 index2.jsp 的 jsp 页面。此页面有 4 个选项卡,分别名为“帐户注册”、“应用程序注册”、“许可证计算器”和“报告模块”。我想将特定按钮的 response.sendRedirect 设置为“报告模块”选项卡。但是,我无法做到。我必须通过代码将其设置为 index2.jsp response.sendRedirect("index2.jsp"); .如何将其设置为“报告模块”选项卡?请帮忙。

【问题讨论】:

  • 你试过response.sendRedirect("index2.jsp?tab=report")然后用js选择这个标签吗?

标签: jsp response.redirect


【解决方案1】:

你应该hash属性:

返回 URL 的锚点部分。

你可以这样做。

  1. 在控制器中重定向到正确的选项卡

response.sendRedirect("index2.jsp#report_module");

  1. 在您的 jsp 文件中显示相应的选项卡

index2.jsp

<script>
$(function () {
var hash = $.trim( window.location.hash );

if (hash) $('.your-css-selector a[href$="'+hash+'"]').trigger('click');

});
</script>

我已从这个答案Opening tab with anchor link 中获取信息。

【讨论】:

    猜你喜欢
    • 2015-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-14
    相关资源
    最近更新 更多