Struts 配置文件 - 重定向 URL 指南
在 Struts 配置文件中,可以使用 '
- 在 'struts.xml' 中定义一个 Action:
<action name='redirect' class='com.example.RedirectAction'>
<result name='success' type='redirect'>/new-url.jsp</result>
</action>
- 在 'RedirectAction' 中返回 'SUCCESS':
public class RedirectAction extends ActionSupport {
public String execute() {
return SUCCESS;
}
}
- 在 '
' 元素中设置 'type' 属性为 'redirect',并指定重定向的 URL。
这样,在访问 '/redirect.action' 时,就会重定向到 '/new-url.jsp'。
原文地址: https://www.cveoy.top/t/topic/jTXQ 著作权归作者所有。请勿转载和采集!