0
<sec:authorize ifAnyGranted="<%=dRoles%>">
    <meta http-equiv="REFRESH" content="0;url=public/First.jsp">
</sec:authorize>

<sec:authorize ifAnyGranted="<%=aRoles%>">      
      <meta http-equiv="REFRESH" content="0;url=public/Second.jsp">
</sec:authorize>

<sec:authorize ifAnyGranted="<%=bRoles%>">  
    <meta http-equiv="REFRESH" content="0;url=public/Third.jsp">
</sec:authorize>

我正在使用弹簧安全。登录成功后,将加载 Startup.jsp ( default-target-url="/Startup.jsp )。我的 Startup.jsp 中有上述代码。我正在使用 spring 安全标签。考虑用户可以访问以上 3 个 jsps .问题是,在IE7中,加载了First.jsp,但在其他浏览器中加载了Third.jsp。如何在两个浏览器中显示相同的jsp?

谢谢!

4

1 回答 1

0

我猜您的情况是,用户在 中dRoles和 中都有角色bRoles,因此您的代码会向浏览器发送两个不同的元刷新。

首先,不要使用元刷新,而是使用真正的重定向或转发(这不应该在 JSP 中完成,而是在控制器、过滤器或 servlet 中完成)。

如果您真的想继续使用 JSP 解决方案,我想这样的事情应该可行:

<c:set var="refreshSent" value="${false}"/>

<sec:authorize ifAnyGranted="<%=dRoles%>">
    <meta http-equiv="REFRESH" content="0;url=public/First.jsp">
    <c:set var="refreshSent" value="${true}"/>
</sec:authorize>

<sec:authorize ifAnyGranted="<%=aRoles%>">
    <c:if test="${!refreshSent}">      
        <meta http-equiv="REFRESH" content="0;url=public/Second.jsp">
        <c:set var="refreshSent" value="${true}"/>
    </c:if>
</sec:authorize>

<sec:authorize ifAnyGranted="<%=bRoles%>">  
    <c:if test="${!refreshSent}">
        <meta http-equiv="REFRESH" content="0;url=public/Third.jsp">
        <c:set var="refreshSent" value="${true}"/>
    </c:if>
</sec:authorize>
于 2012-09-20T10:38:00.313 回答