使用web.xml和struts.xml的配置文件,并在前面的章节中,已经看到我们的例子中曾使用这两个文件,让我解释以及其他文件。
web.xml配置文件是一个J2EE的配置文件,决定如何处理元素的HTTP请求由servlet容器。严格来说它不是一个Struts2的配置文件,但它是Struts2的工作需要进行配置的文件。
如前所述,这个文件为任何Web应用程序提供了一个切入点。 Struts2 应用程序的入口点,将是一个部署描述符(web.xml)中定义的过滤器。因此,我们将定义在web.xml中的FilterDispatcher是类的项。需要创建的文件夹的WebContent/ WEB-INF下web.xml文件。
这是第一个配置文件,将需要配置,如果没有一个模板或工具,可生成(如Eclipse或Maven2的)的帮助下开始。以下是web.xml文件中的内容,我们用我们的最后一个例子。
<span class="pun" style="margin: 0px; padding: 0px;"><?</span><span class="pln" style="margin: 0px; padding: 0px;">xml version</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="str" style="margin: 0px; padding: 0px;">"1.0"</span><span class="pln" style="margin: 0px; padding: 0px;"> encoding</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="str" style="margin: 0px; padding: 0px;">"UTF-8"</span><span class="pun" style="margin: 0px; padding: 0px;">?></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><web-app</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">xmlns:xsi</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"http://www.w3.org/2001/XMLSchema-instance"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">xmlns</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"http://java.sun.com/xml/ns/javaee"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">xmlns:web</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">xsi:schemaLocation</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">id</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"WebApp_ID"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">version</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"3.0"</span><span class="tag" style="margin: 0px; padding: 0px;">></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><display-name></span><span class="pln" style="margin: 0px; padding: 0px;">Struts 2</span><span class="tag" style="margin: 0px; padding: 0px;"></display-name></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><welcome-file-list></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><welcome-file></span><span class="pln" style="margin: 0px; padding: 0px;">index.jsp</span><span class="tag" style="margin: 0px; padding: 0px;"></welcome-file></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></welcome-file-list></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><filter></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><filter-name></span><span class="pln" style="margin: 0px; padding: 0px;">struts2</span><span class="tag" style="margin: 0px; padding: 0px;"></filter-name></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><filter-class></span><span class="pln" style="margin: 0px; padding: 0px;"> org.apache.struts2.dispatcher.FilterDispatcher </span><span class="tag" style="margin: 0px; padding: 0px;"></filter-class></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></filter></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><filter-mapping></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><filter-name></span><span class="pln" style="margin: 0px; padding: 0px;">struts2</span><span class="tag" style="margin: 0px; padding: 0px;"></filter-name></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><url-pattern></span><span class="pln" style="margin: 0px; padding: 0px;">/*</span><span class="tag" style="margin: 0px; padding: 0px;"></url-pattern></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></filter-mapping></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></web-app></span>
请注意,我们Struts 2的过滤器映射为/*, /*.action这意味着所有的URL将被解析struts的过滤器。我们将覆盖时,我们将通过“注释”一章。
struts.xml文件中包含的配置信息,将为动作开发被修改。这个文件可以被用来覆盖默认设置的应用程序,例如struts.devMode=false 和其他设置中定义的属性文件。这个文件可以被文件夹WEB-INF/classes下创建
让我们来看看在我们struts.xml文件中创建的Hello World的例子在前面的章节中解释。
<span class="pun" style="margin: 0px; padding: 0px;"><?</span><span class="pln" style="margin: 0px; padding: 0px;">xml version</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="str" style="margin: 0px; padding: 0px;">"1.0"</span><span class="pln" style="margin: 0px; padding: 0px;"> encoding</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="str" style="margin: 0px; padding: 0px;">"UTF-8"</span><span class="pun" style="margin: 0px; padding: 0px;">?></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="dec" style="margin: 0px; padding: 0px;"><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><struts></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><constant</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">name</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"struts.devMode"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">value</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"true"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;">/></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><package</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">name</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"helloworld"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">extends</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"struts-default"</span><span class="tag" style="margin: 0px; padding: 0px;">></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><action</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">name</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"hello"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">class</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"com.yiibai.struts2.HelloWorldAction"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">method</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"execute"</span><span class="tag" style="margin: 0px; padding: 0px;">></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><result</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">name</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"success"</span><span class="tag" style="margin: 0px; padding: 0px;">></span><span class="pln" style="margin: 0px; padding: 0px;">/HelloWorld.jsp</span><span class="tag" style="margin: 0px; padding: 0px;"></result></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></action></span><span class="pln" style="margin: 0px; padding: 0px;"> <-- more actions can be listed here --> </span><span class="tag" style="margin: 0px; padding: 0px;"></package></span><span class="pln" style="margin: 0px; padding: 0px;"> <-- more packages can be listed here --> </span><span class="tag" style="margin: 0px; padding: 0px;"></struts></span>
首先要注意的是DOCTYPE。所有的Struts配置文件需要有正确的doctype所示,我们的小例子。 <struts>根标签的元素,我们声明不同的包使用<package>标签。 <package>允许分离和模块化的配置。这是非常有用的,当有一个大项目,项目被划分成不同的模块。
也就是说,如果项目有三个域 - business_applicaiton ,customer_application 和 staff_application,可以创建三个包和存储相关的动作,在适当的包。包装标签具有以下属性:
属性 | 描述 |
---|---|
name (required) | The unique identifier for the package |
extends | Which package does this package extend from? By default, we use struts-default as the base package. |
abstract | If marked true, the package is not available for end user consumption. |
namesapce | Unique namespace for the actions |
随着name和value属性恒定的标签将被用于覆盖default.properties中定义以下属性,就像我们刚刚设置struts.devMode属性。 Settingstruts.devMode属性可以让我们看到更多的调试消息,在日志文件中。
我们定义动作标记对应的每一个URL,我们要访问,我们定义了一个类的execute()方法,将访问时,我们将访问相应的URL。
结果决定得到执行动作后返回给浏览器。从操作返回的字符串应该是一个结果的名称。以上,或者作为一个“global”的结果,可包中的每一个动作,结果被配置每次动作。结果有可选的名称和类型属性。默认名称的值是“success”。
随着时间的推移,struts.xml文件可以逐步扩展,打破它包是模块化的方式之一,但Struts提供了另一种模块化struts.xml文件。可以将文件分割为多个XML文件,并以下列方式将它们导入。
<span class="pun" style="margin: 0px; padding: 0px;"><?</span><span class="pln" style="margin: 0px; padding: 0px;">xml version</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="str" style="margin: 0px; padding: 0px;">"1.0"</span><span class="pln" style="margin: 0px; padding: 0px;"> encoding</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="str" style="margin: 0px; padding: 0px;">"UTF-8"</span><span class="pun" style="margin: 0px; padding: 0px;">?></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="dec" style="margin: 0px; padding: 0px;"><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><struts></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><include</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">file</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"my-struts1.xml"</span><span class="tag" style="margin: 0px; padding: 0px;">/></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><include</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">file</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"my-struts2.xml"</span><span class="tag" style="margin: 0px; padding: 0px;">/></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></struts></span>
其他的配置文件,我们还没有涉及到在struts-default.xml中。这个文件包含了Struts的标准配置设置,就不必去触摸项目的这些99.99%设置。出于这个原因,我们不打算对这个文件介绍太多。如果有兴趣,不妨看看到struts2的核心2.2.3.jar文件default.properties文件。
在struts-config.xml 配置文件是在Web客户端组件的视图和模型之间的链接,但99.99%不会有触碰这些设置在项目中。基本配置文件包含以下主要内容:
SN | 拦截 & 描述 |
---|---|
1 | struts-config This is the root node of the configuration file. |
2 | form-beans This is where you map your ActionForm subclass to a name. You use this name as an alias for your ActionForm throughout the rest of the struts-config.xml file, and even on your JSP pages. |
3 | global forwards This section maps a page on your webapp to a name. You can use this name to refer to the actual page. This avoids hardcoding URLs on your web pages. |
4 | action-mappings This is where you declare form handlers and they are also known as action mappings. |
5 | controller This section configures Struts internals and rarely used in practical situations. |
6 | plug-in This section tells Struts where to find your properties files, which contain prompts and error messages |
下面是示例struts-config.xml文件:
<span class="pun" style="margin: 0px; padding: 0px;"><?</span><span class="pln" style="margin: 0px; padding: 0px;">xml version</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="str" style="margin: 0px; padding: 0px;">"1.0"</span><span class="pln" style="margin: 0px; padding: 0px;"> encoding</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="str" style="margin: 0px; padding: 0px;">"ISO-8859-1"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="pun" style="margin: 0px; padding: 0px;">?></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="dec" style="margin: 0px; padding: 0px;"><!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd"></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><struts-config></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="com" style="margin: 0px; padding: 0px;"><!-- ========== Form Bean Definitions ============ --></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><form-beans></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><form-bean</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">name</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"login"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">type</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"test.struts.LoginForm"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;">/></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></form-beans></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="com" style="margin: 0px; padding: 0px;"><!-- ========== Global Forward Definitions ========= --></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><global-forwards></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></global-forwards></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="com" style="margin: 0px; padding: 0px;"><!-- ========== Action Mapping Definitions ======== --></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><action-mappings></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><action</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">path</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"/login"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">type</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"test.struts.LoginAction"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;">></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><forward</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">name</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"valid"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">path</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"/jsp/MainMenu.jsp"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;">/></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><forward</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">name</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"invalid"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">path</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"/jsp/LoginView.jsp"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;">/></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></action></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></action-mappings></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="com" style="margin: 0px; padding: 0px;"><!-- ========== Controller Definitions ======== --></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"><controller</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">contentType</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"text/html;charset=UTF-8"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">debug</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"3"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">maxFileSize</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"1.618M"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">locale</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"true"</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="atn" style="margin: 0px; padding: 0px;">nocache</span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="atv" style="margin: 0px; padding: 0px;">"true"</span><span class="tag" style="margin: 0px; padding: 0px;">/></span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="tag" style="margin: 0px; padding: 0px;"></struts-config></span>
struts-config.xml文件的更多详细信息,请查看 Struts 文档。
此配置文件提供了一种机制来改变框架的默认行为。 struts.properties配置文件内包含的属性其实也可以被配置在web.xml中使用init-param中,以及在struts.xml的配置文件中使用恒定的标签。但如果喜欢保持独立和特定Struts,那么可以创建这个文件的文件夹下的WEB-INF/classes。
在这个文件中配置的值将覆盖默认值配置default.properties这是包含在struts2-core-x.y.z.jar 分布。有几个的属性,可能会考虑改变使用struts.properties文件:
<span class="com" style="margin: 0px; padding: 0px;">### When set to true, Struts will act much more friendly for developers</span><span class="pln" style="margin: 0px; padding: 0px;"> struts</span><span class="pun" style="margin: 0px; padding: 0px;">.</span><span class="pln" style="margin: 0px; padding: 0px;">devMode </span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="kwd" style="margin: 0px; padding: 0px;">true</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="com" style="margin: 0px; padding: 0px;">### Enables reloading of internationalization files</span><span class="pln" style="margin: 0px; padding: 0px;"> struts</span><span class="pun" style="margin: 0px; padding: 0px;">.</span><span class="pln" style="margin: 0px; padding: 0px;">i18n</span><span class="pun" style="margin: 0px; padding: 0px;">.</span><span class="pln" style="margin: 0px; padding: 0px;">reload </span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="kwd" style="margin: 0px; padding: 0px;">true</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="com" style="margin: 0px; padding: 0px;">### Enables reloading of XML configuration files</span><span class="pln" style="margin: 0px; padding: 0px;"> struts</span><span class="pun" style="margin: 0px; padding: 0px;">.</span><span class="pln" style="margin: 0px; padding: 0px;">configuration</span><span class="pun" style="margin: 0px; padding: 0px;">.</span><span class="pln" style="margin: 0px; padding: 0px;">xml</span><span class="pun" style="margin: 0px; padding: 0px;">.</span><span class="pln" style="margin: 0px; padding: 0px;">reload </span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="kwd" style="margin: 0px; padding: 0px;">true</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="com" style="margin: 0px; padding: 0px;">### Sets the port that the server is run on</span><span class="pln" style="margin: 0px; padding: 0px;"> struts</span><span class="pun" style="margin: 0px; padding: 0px;">.</span><span class="pln" style="margin: 0px; padding: 0px;">url</span><span class="pun" style="margin: 0px; padding: 0px;">.</span><span class="pln" style="margin: 0px; padding: 0px;">http</span><span class="pun" style="margin: 0px; padding: 0px;">.</span><span class="pln" style="margin: 0px; padding: 0px;">port </span><span class="pun" style="margin: 0px; padding: 0px;">=</span><span class="pln" style="margin: 0px; padding: 0px;"> </span><span class="lit" style="margin: 0px; padding: 0px;">8080</span>
这里井号(#)开头的行会被假定作为注释,它将被Struts 2忽略。