---
title: "浅析struts-config.xml文件"
author: "itlangzicn"
date: "2010-02-04T19:18:30Z"
tags: []
categories: ["企业架构"]
slug: "struts-config-xml"
draft: false
lastmod: "2010-02-04T19:18:30Z"
id: 587746
url: "https://itlangzicn.iteye.com/blog/587746"
---

&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;

&lt;!DOCTYPE struts-config PUBLIC  
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"  
          "[http://struts.apache.org/dtds/struts-config\_1\_3.dtd](http://struts.apache.org/dtds/struts-config_1_3.dtd)"&gt;  
&lt;struts-config&gt;

 &lt;form-beans&gt;  
  &lt;form-bean name="regForm"  
   type="cn.itcast.web.struts.forms.RegForm"/&gt;  
 &lt;/form-beans&gt;

//有&lt;form-beans&gt;节点就有FormBeanConfig类与之对应，在这个类中有相应的方法和属性  
//例如：有，属性：name，type等。方法：getName(),setName(),getType(),setType()等方法  
   
 &lt;action-mappings&gt;  
   
  &lt;action path="/reg"  
   type="cn.itcast.web.struts.actions.RegAction"  
   name="regForm"  
   input="/user-reg.jsp"&gt;  
   &lt;forward name="success" path="/reg-success.jsp"/&gt;  
  &lt;/action&gt;  
   
 &lt;/action-mappings&gt;  
// 有&lt;action-mappings&gt;节点就有相应的ActionConfig类与之对应，在这个类中有相应的方法和属  
// 性，例如：属性：path，type，方法：getPath(),setPath,getInput() 等等

 &lt;message-resources parameter="MessageResources"&gt;&lt;/message-resources&gt;

// 有&lt;message-resources&gt;节点就有MessageResourcesConfig类与之对应，在这个类中有相应的// 方法和属性。例如：setParameter(),getParameter()等等  
&lt;/struts-config&gt;

 

 

注：对于配置文件，框架都会有相应的类与之对应，使配置文件中的属性值都变成了各个类中的属性值，执行时通过get方法得到。