struts 如何重定向至外部地址
在 Struts 中,可以使用 redirect 结果类型来重定向到外部地址。
例如,以下是一个在 struts.xml 中配置的重定向到百度首页的示例:
<action name="redirectExample" class="com.example.RedirectAction">
<result name="success" type="redirect">http://www.baidu.com</result>
</action>
在 RedirectAction 类中,可以返回 SUCCESS 结果来触发重定向:
public class RedirectAction extends ActionSupport {
public String execute() throws Exception {
return SUCCESS;
}
}
原文地址: https://www.cveoy.top/t/topic/cyOG 著作权归作者所有。请勿转载和采集!