What do we will configure in struts-config.xml?
>> Friday, June 24, 2011
STRUTS-CONFIG.XML
The main control file in the Struts framework is the struts-config.xml XML file, where action mappings are specified.
This file’s structure is described by the struts-config DTD file, which is defined at http://jakarta.apache.org/struts/. A copy of the DTD can be found on the /docs/dtds subdirectory of the framework’s installation root directory. The top-level element is struts-config.
STRUTS-CONFIG.XML
The main control file in the Struts framework is the struts-config.xml XML file, where action mappings are specified.
This file’s structure is described by the struts-config DTD file, which is defined at http://jakarta.apache.org/struts/. A copy of the DTD can be found on the /docs/dtds subdirectory of the framework’s installation root directory. The top-level element is struts-config.
STRUTS-CONFIG.XML
<struts-config>
<!-- ========== Data Source Decleration ============ -->
<data-sources>
<data-source type="org.apache.tomcat.
dbcp.dbcp.BasicDataSource">
<set-property
property="driverClassName"
value="com.mysql.jdbc.Driver" />
<set-property
property="url"
value="jdbc:mysql://localhost:3306
/strutsdatabase?autoReconnect=true" />
<set-property
property="username"
value="root" />
<set-property
property="password"
value="" />
<set-property
property="maxActive"
value="10" />
<set-property
property="maxWait"
value="5000" />
<set-property
property="defaultAutoCommit"
value="false" />
<set-property
property="defaultReadOnly"
value="false" />
<set-property
property="validationQuery"
value="SELECT COUNT(*) FROM test" />
</data-source>
</data-sources>
<!-- ========== Form Bean Definitions ============ -->
<form-beans>
<form-bean name="login" type="com.bhaskar.NewActionForm" />
<form-bean name="UserForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="givenName"type="java.lang.String"
/>
<form-property name="firstname" type="java.lang.String"/>
</form-bean>
<!-- ========== Global Forwards Definitions ============ -->
<global-forwards type="org.apache.struts.action.ActionForward">
<forward name="sucess" path="mypage.jsp" />
</global-forwards>
<!-- ========== Global Exceptions Definitions ============ -->
<global-exceptions>
<exception key="some.key" type="java.lang.NullPointerException"
path="/WEB-INF/errors/null.jsp"/>
</global-exceptions>
<!-- ========== Action Mappings Definitions ============ -->
<action-mappings>
<action
path="/logon"
type="org.apache.struts.webapp.example.LogonAction"
name="logonForm"
scope="request"
input="/logon.jsp"
unknown="false"
validate="true" >
<forward name="key" path="/me.jsp"/>
<forward name="key1" path="/me1.jsp"/>
</action>
</action-mappings>
<!-- ========== Controller ============ -->
<controller
processorClass="org.apache.struts.action.RequestProcessor"
contentType="text/html"/>;
<!-- ========== Message Resources ============ -->
<message-resources parameter="MyWebAppResources" null="false" />
<!-- ========== PlugIns ============ -->
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/>
</plug-in>
</struts-config>
<!-- ========== All about Configuration File ============ -->

0 comments:
Post a Comment