正确配置多个struts配置文件示例
Posted royal_coffee
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了正确配置多个struts配置文件示例相关的知识,希望对你有一定的参考价值。
struts-config.xml:
<?
xml version="1.0" encoding="UTF-8"
?>
<! DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd" >
< struts-config >
< data-sources />
<!-- ========== Form Bean Definitions ================= -->
< form-beans />
<!-- ============== Global exceptions ============== -->
< global-exceptions />
<!-- ============== Global forwards ============== -->
< global-forwards />
<!-- ========== Action Mapping Definitions ============ -->
< action-mappings />
<!-- ========== Message Resources Definitions =================== -->
< message-resources parameter ="com.ecic.dps.web.ApplicationResources" />
<!-- ========== Struts Validator plugin =================== -->
< plug-in className ="org.apache.struts.validator.ValidatorPlugIn" >
< set-property property ="pathnames"
value ="/WEB-INF/validator-rules.xml,/WEB-INF/validations.xml" />
</ plug-in >
</ struts-config >
<! DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd" >
< struts-config >
< data-sources />
<!-- ========== Form Bean Definitions ================= -->
< form-beans />
<!-- ============== Global exceptions ============== -->
< global-exceptions />
<!-- ============== Global forwards ============== -->
< global-forwards />
<!-- ========== Action Mapping Definitions ============ -->
< action-mappings />
<!-- ========== Message Resources Definitions =================== -->
< message-resources parameter ="com.ecic.dps.web.ApplicationResources" />
<!-- ========== Struts Validator plugin =================== -->
< plug-in className ="org.apache.struts.validator.ValidatorPlugIn" >
< set-property property ="pathnames"
value ="/WEB-INF/validator-rules.xml,/WEB-INF/validations.xml" />
</ plug-in >
</ struts-config >
struts-demaintenance.xml:
<?
xml version="1.0" encoding="UTF-8"
?>
<! DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd" >
< struts-config >
< form-beans >
< form-bean name ="addDeclarationForm" type ="com.ecic.dps.web.form.AddDeclarationForm" />
</ form-beans >
< global-forwards >
</ global-forwards >
< action-mappings >
< action
attribute ="addDeclarationForm"
input ="/DeMaintenance/newDeclaration.jsp"
name ="addDeclarationForm"
path ="/addDeclaration"
scope ="request"
type ="com.ecic.dps.web.action.AddDeclarationAction" >
< forward name ="success" path ="/index.jsp" />
< forward name ="fail" path ="/DeMaintenance/newDeclaration.jsp" />
</ action >
</ action-mappings >
</ struts-config >
<! DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd" >
< struts-config >
< form-beans >
< form-bean name ="addDeclarationForm" type ="com.ecic.dps.web.form.AddDeclarationForm" />
</ form-beans >
< global-forwards >
</ global-forwards >
< action-mappings >
< action
attribute ="addDeclarationForm"
input ="/DeMaintenance/newDeclaration.jsp"
name ="addDeclarationForm"
path ="/addDeclaration"
scope ="request"
type ="com.ecic.dps.web.action.AddDeclarationAction" >
< forward name ="success" path ="/index.jsp" />
< forward name ="fail" path ="/DeMaintenance/newDeclaration.jsp" />
</ action >
</ action-mappings >
</ struts-config >
web.xml:
<?
xml version="1.0" encoding="UTF-8"
?>
< web-app xmlns ="http://java.sun.com/xml/ns/j2ee" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" version ="2.4" xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
< servlet >
< servlet-name > action </ servlet-name >
< servlet-class > org.apache.struts.action.ActionServlet </ servlet-class >
< init-param >
< param-name > config </ param-name >
< param-value > /WEB-INF/struts-config.xml, /WEB-INF/struts-demaintenance.xml, /WEB-INF/struts-settingsystem.xml </ param-value >
</ init-param >
< init-param >
< param-name > debug </ param-name >
< param-value > 3 </ param-value >
</ init-param >
< init-param >
< param-name > detail </ param-name >
< param-value > 3 </ param-value >
</ init-param >
< load-on-startup > 0 </ load-on-startup >
</ servlet >
< servlet-mapping >
< servlet-name > action </ servlet-name >
< url-pattern > *.do </ url-pattern >
</ servlet-mapping >
< welcome-file-list >
< welcome-file > index.jsp </ welcome-file >
</ welcome-file-list >
</ web-app >
< web-app xmlns ="http://java.sun.com/xml/ns/j2ee" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" version ="2.4" xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
< servlet >
< servlet-name > action </ servlet-name >
< servlet-class > org.apache.struts.action.ActionServlet </ servlet-class >
< init-param >
< param-name > config </ param-name >
< param-value > /WEB-INF/struts-config.xml, /WEB-INF/struts-demaintenance.xml, /WEB-INF/struts-settingsystem.xml </ param-value >
</ init-param >
< init-param >
< param-name > debug </ param-name >
< param-value > 3 </ param-value >
</ init-param >
< init-param >
< param-name > detail </ param-name >
< param-value > 3 </ param-value >
</ init-param >
< load-on-startup > 0 </ load-on-startup >
</ servlet >
< servlet-mapping >
< servlet-name > action </ servlet-name >
< url-pattern > *.do </ url-pattern >
</ servlet-mapping >
< welcome-file-list >
< welcome-file > index.jsp </ welcome-file >
</ welcome-file-list >
</ web-app >
以上是关于正确配置多个struts配置文件示例的主要内容,如果未能解决你的问题,请参考以下文章