|
蓝森林 http://www.lslnet.com 2006年6月6日 10:18
[求教]Struts初级问题,详细描述见内。
按照教程,完成了一个最基本的例子。例子中有配置文件“struts-config.xml”,内容如下:
[code]
<?xml version="1.0" encoding="ISO-8859-1" ?>;
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">;
<!--
This is the Struts configuration file for the "Hello!" sample application
-->;
<struts-config>;
<!-- ======== Form Bean Definitions =================================== -->;
<form-beans>;
<form-bean name="HelloForm" type="hello.HelloForm"/>;
</form-beans>;
<!-- ========== Action Mapping Definitions ============================== -->;
<action-mappings>;
<!-- Say Hello! -->;
<action path = "/HelloWorld"
type = "hello.HelloAction"
name = "HelloForm"
scope = "request"
validate = "true"
input = "/hello.jsp"
>;
<forward name="SayHello" path="/hello.jsp" />;
</action>;
</action-mappings>;
<!-- ========== Message Resources Definitions =========================== -->;
<message-resources parameter="hello.application"/>;
</struts-config>;
[/code]
现在里面的内容基本清楚,了。例子里有个包叫“hello”,标题、网页内容使用的资源文件为“WEB-INF/classes/hello/application.property”。我想在此基础上再加一个自己写的包“hello2”,使用资源文件“WEB-INF/classes/hello2/application.property”。
现在我的“struts-config.xml”内容为:
[code]
<?xml version="1.0" encoding="ISO-8859-1" ?>;
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">;
<!--
This is the Struts configuration file for the "Hello!" sample application
-->;
<struts-config>;
<!-- ======== Form Bean Definitions =================================== -->;
<form-beans>;
<form-bean name="HelloForm" type="hello.HelloForm"/>;
</form-beans>;
<form-beans>;
<form-bean name="Hello2Form" type="hello2.Hello2Form"/>;
</form-beans>;
<!-- ========== Action Mapping Definitions ============================== -->;
<action-mappings>;
<!-- Say Hello! -->;
<action path = "/HelloWorld"
type = "hello.HelloAction"
name = "HelloForm"
scope = "request"
validate = "true"
input = "/hello.jsp"
>;
<forward name="SayHello" path="/hello.jsp" />;
</action>;
<!-- Say Hello2! -->;
<action path = "/HelloWorld"
type = "hello2.Hello2Action"
name = "Hello2Form"
scope = "request"
validate = "true"
input = "/hello2.jsp"
>;
<forward name="SayHello" path="/hello2.jsp" />;
</action>;
</action-mappings>;
<!-- ========== Message Resources Definitions =========================== -->;
<message-resources parameter="hello.application"/>;
</struts-config>;
[/code]
指定资源文件的看起来是这行:
[code]
<message-resources parameter="hello.application"/>;
[/code]
我尚不清楚怎样为另外一个包指定另外一处资源文件。
特此求教,谢谢。 |
[求教]Struts初级问题,详细描述见内。
首先,你的文件名写错了不是*.property,而是*.properties;其次,只可以加入一个资源包,如果在同一个目录下有两个或者两个以上的资源包,系统只会默认一个。 |
| |