配置Struts
web.xml
Struts程序的ActionServlet是整个程序的控制中心,且可以被继承,当Struts程序启动的时候,需要在web.xml中找到它并启动,然后让它自己工作。所以要配置该servlet,即<servlet></servlet>,<servlet-mapping></servlet-mapping>
可能需要在<servlet></servlet>内配置四个初始化变量:application,config,debug,detail
另一个需要配置在web.xml中的组件是标记库(可选):
<taglib>
<taglib-uri></taglib-uri>
<taglib-locatiion></taglib-locatiion>
</taglib>
<taglib-uri>给出程序中使用的标记库的名称,<taglib-location>标记库存放的位置
struts-config.xml
tomcat运行的时候,会加载工程的web.xml文件,此加载过程中初始化struts-config.xml文件。struts-config.xml文件告诉程序要加载Struts组件的时候,在哪个位置寻找。
根元素< struts-config>有8个子元素:data-sources, form-beans, global-exceptions, global-forwards, action-mappings, controller, message-resources, plug-in
<struts-config> <data-sources></data-sources> <form-beans> <form-bean name="" type=""> <form-peroperty name="" type=""/> </form-bean> </form-beans> <global-exceptions></global-exceptions> <global-forwards> <forward name="fail" path="/fail.do"/> </global-forwards> <action-mappings> <action path="" type="" name="" ></action> </action-mappings> <controller processorClass=""/> <message-resources parameter="" /> <plug-in></plug-in> </struts-config> |