在 Struts 配置文件中,可以使用 <result> 元素来重定向 Url。具体步骤如下:

  1. struts.xml 中定义一个 Action:
<action name="redirect" class="com.example.RedirectAction">
    <result name="success" type="redirect">/new-url.jsp</result>
</action>
  1. RedirectAction 中返回 SUCCESS
public class RedirectAction extends ActionSupport {
    public String execute() {
        return SUCCESS;
    }
}
  1. <result> 元素中设置 type 属性为 redirect,并指定重定向的 Url。

这样,在访问 /redirect.action 时,就会重定向到 /new-url.jsp

Struts 配置文件中如何重定向Url

原文地址: https://www.cveoy.top/t/topic/crq3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录