---
title: "<global-forwards/>子元素"
author: "java_frog"
date: "2009-03-13T11:53:15Z"
tags: []
slug: "global-forwards"
draft: false
lastmod: "2009-03-13T11:53:15Z"
id: 348536
url: "https://java-frog.iteye.com/blog/348536"
---

<global-forwards/>子元素

全局转发可以定义几个<forward/>子元素，Struts首先会在<action-mappings>元素中查找对应的<forward>,若找不到，则到全局转发配置中查找。

语法如下：
<global-forwards>
<forward name="唯一的转发的逻辑名称"
path="要转发到的物理资源路径"/>
</global-forwards>

除了name及path属性之外，还有一个redirect属性，如果为true，则调用HttpServletResponse.sendRedirect()方法进行重定向的操作，否则用RequestDispathcer.forward()方法来转发，默认为false

注意：如果为true，则用HttpServletResponse.sendRedirect()方法，此时存储在原来的HttpSerletRequest中的值会丢失。

实例
<global-forwards>
<forward name="toindex" path="/index.jsp"/>
</global-forwards>