java - struts2 jsp页面中的重定向标签

标签 java struts2

我在struts中有一个jsp页面,如下所示:

<%@taglib prefix="s" uri="/struts-tags" %>

<s:if test="#session.variablename == null" >
    **<s:action name="loginForm" />**
</s:if>

<html>
    <head>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
    </head>
    <body>
    <h1>Hello World!</h1> 
    <s:a href="doctorLogout">Logout</s:a> 
 <s:include value="/WEB-INF/doctor/doctorFooter.jsp" ></s:include>

如果session未设置,我需要将此页面重定向到 struts.xml 中的操作页。我已经尝试过<jsp:forward />标签而不是 <s:action /> ,但是jsp重定向到错误页面。这有什么解决办法吗? struts2中是否存在重定向标签?

最佳答案

IMO 这种工作属于拦截器,或者在最坏的情况下,属于基本操作类。 JSP 中的这种逻辑使测试变得更加困难。

Struts 2 没有重定向标签;使用 JSTL 的 <c:redirect>如果您要将这种逻辑放入 JSP 中,请使用 标记。

关于java - struts2 jsp页面中的重定向标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8416053/

相关文章:

java - 使用私有(private)类访问 JTextField

java - struts html字符编码和解码

struts2 - 在另一个 Action 中通过构造函数调用Struts Action 是一种好习惯吗?

java - java中如何在图像格式之前连接

java - Tomcat 部署错误

java - 本地主机上的 NotBoundException

java - 使用 Struts2 标签转义字符串

java - 在 Struts-2 中使用 iText 生成 PDF : result type stream not working

javascript - Struts 2 表单在不使用索引的情况下将参数绑定(bind)到集合

java - Spring Integration 中的 Http Outbound Gateway 错误处理