在 Struts 配置文件中,可以使用 '' 元素来重定向 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. 在 '' 元素中设置 'type' 属性为 'redirect',并指定重定向的 URL。

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


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

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