Saturday, May 12, 2012

Struts2.0 sample "struts.xml" configuration..


Main ::::::::::::::::::::::::::::::::::::::

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<!-- STRUTS CONSTANTS START -->
<!--
STRUTS CONSTANT FOR LOADING CONFIGURATIONS AND PROPERTIES DURING
DEVELOPMENT PHASE, WHICH IS BY DEFAULT TRUE.WE WILL MAKE IT FALSE IN
PRODUCTION ENVIRONMENT.
-->
<constant name="struts.devMode" value="false" />
<!--
STRUTS CONSTANT FOR LOADING APPLICATION LEVEL PROPERTIES,USED FOR
GLOBALIZATION & LOCALIZATION.
We can provide multiple application resource files using comma seperated.
-->
<constant name="struts.custom.i18n.resources" value="com.resources.ApplicationResources,com.resources.ApplicationResourcesException" />
<!--
STRUTS CONSTANT FOR MAKING DYNAMICMETHODINVOCATION PROPERTY OF
FRAMEWORK FALSE, BY DEFAULT IT IS TRUE.IT IS DONE FOR SECURITY
REASONS,SO THAT AN ACTION CAN NOT BE ACCESSED WITH WILDCARDS.
-->
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<!--
STRUTS CONSTANT FOR MENTIONING THAT STRUTS2 FRAMEWORK IS INTEGERATING
WITH SPRING 3
-->
<constant name="struts.objectFactory"
value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
<!--
STRUTS CONSTANTS FOR ALLOWING STATIC METHODS TO BE ACCESSED USING OGNL
EXPRESSION DIRECTLY IN JSP. SYNTAX FOR ACCESSING A STATIC METHOD IS:
<s:property value="@com.utility.Utilities@getSessionCount()"/> I.E,
<s:property value="@CLASSNAME@STATIC-METHOD-NAME"/>
-->
<constant name="struts.ognl.allowStaticMethodAccess" value="true" />
<!-- STRUTS CONSTANTS END -->

<!--APPLICATION LEVEL DECLARATIONS START-->
<package name="strutsSpringDemo" extends="struts-default">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<!-- INTERCEPTORS AND MAPPINGS START -->
<interceptors>
<interceptor name="sessionInterceptor" class="com.interceptor.SessionInterceptor" />
<interceptor name="appCommonInterceptor" class="com.interceptor.AppCommonInterceptor" />
<interceptor-stack name="sessionCheckStack">
   <interceptor-ref name="exception"/>
               <interceptor-ref name="alias"/>
               <interceptor-ref name="servletConfig"/>
       <!-- LOGGER INTERCEPTOR, GIVES THE INFORMATION OF EXECUTED ACTION -->
   <interceptor-ref name="logger"/>
   <!-- TIMER INTERCEPTOR, GIVES THE INFORMATION OF EXECUTED ACTION AND METHOD AND ITS EXECUTION TIME -->
   <interceptor-ref name="timer"/>
             
               <interceptor-ref name="sessionInterceptor"/>
               <interceptor-ref name="i18n"/>
               <interceptor-ref name="prepare"/>
               <interceptor-ref name="chain"/>
               <interceptor-ref name="debugging"/>
               <interceptor-ref name="profiling"/>
               <interceptor-ref name="scopedModelDriven"/>
               <interceptor-ref name="modelDriven"/>
               <interceptor-ref name="fileUpload"/>
               <interceptor-ref name="checkbox"/>
               <interceptor-ref name="staticParams"/>
               <interceptor-ref name="actionMappingParams"/>
               <interceptor-ref name="params">
                 <param name="excludeParams">dojo\..*,^struts\..*</param>
               </interceptor-ref>
               <interceptor-ref name="conversionError"/>
               <interceptor-ref name="validation">
                   <param name="excludeMethods">input,back,cancel,browse</param>
               </interceptor-ref>
               <interceptor-ref name="workflow">
                   <param name="excludeMethods">input,back,cancel,browse</param>
               </interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="sessionCheckStack" />
<default-action-ref name="homeAction" />
<!-- INTERCEPTORS AND MAPPINGS END-->
<!-- GLOBAL RESULTS AND MAPPINGS START-->
<global-results>
<result name="sessionExpired">/login.jsp?sess=expired</result>
<result name="login">/login.jsp</result>
<result name="Exception" type="chain">demoExceptionHandler</result>
<result name="securityError">/jsp/securityError.jsp</result>
</global-results>
<!-- GLOBAL RESULTS AND MAPPINGS END-->
<!-- GLOBAL EXCEPTIONS AND MAPPINGS START-->
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception"
result="Exception" />
</global-exception-mappings>
<!-- GLOBAL EXCEPTIONS ACTION -->
<action name="demoExceptionHandler" class="com.exception.GlobalException">
<result name="demoException">/jsp/error.jsp</result>
</action>
<!-- GLOBAL EXCEPTIONS AND MAPPINGS START-->
</package>
<!--APPLICATION LEVEL DECLARATIONS END-->

<!-- INCLUDING OTHER STRUTS CONFIG XMLs MODULE BASED -->
<include file="struts-auth.xml" />
<include file="struts-userMgmt.xml" />
<include file="struts-utility.xml" />
<!-- INCLUDING OTHER STRUTS CONFIG XMLs MODULE BASED -->
</struts>
##################################################################################

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<package name="auth" extends="strutsSpringDemo">
<!-- AUTHENTICATION ACTIONS AND MAPPINGS START-->
<action name="loginAction" class="com.action.LoginAction"
method="doLogin">
<exception-mapping exception="java.lang.SecurityException"
result="securityError"></exception-mapping>
<result name="input">/login.jsp</result>
<result name="success" type="redirect">${redirectUrl}</result>
</action>
<action name="logOut" class="com.action.LogoutAction" method="logOut">
<result name="success">/login.jsp</result>
</action>
<!-- AUTHENTICATION ACTIONS AND MAPPINGS END-->
</package>
</struts>
##################################################################################

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<package name="userMgmt" extends="strutsSpringDemo">
<!-- USER MGMT ACTIONS AND MAPPINGS START-->
<action name="homeAction" class="com.action.HomeAction" method="homePage">
<result name="success" type="tiles">/homePage.tiles</result>
</action>
<action name="userProfile" class="com.action.HomeAction"
method="getUserProfileAction">
<result name="success" type="stream">
<param name="contentType">text/html</param>
<param name="inputName">inputStream</param>
</result>
</action>
<action name="changePassword" class="com.action.HomeAction"
method="changePasswordAction">
<result name="success" type="stream">
<param name="contentType">text/html</param>
<param name="inputName">inputStream</param>
</result>
</action>
<action name="updateProfile" class="com.action.HomeAction"
method="updateUserProfileAction">
<result name="success" type="stream">
<param name="contentType">text/html</param>
<param name="inputName">inputStream</param>
</result>
</action>
<action name="createUser" class="com.action.HomeAction" method="createUserAction">
<result name="success" type="stream">
<param name="contentType">text/html</param>
<param name="inputName">inputStream</param>
</result>
</action>
<action name="sortOnKey" class="com.action.HomeAction" method="sortOnKey">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="execAndWait">
<param name="delay">50</param>
<param name="delaySleepInterval">150</param>
</interceptor-ref>
<result name="wait">jsp/waitProcess.jsp</result>
<result name="success" type="tiles">/homePage.tiles</result>
</action>
<action name="sortOnVal" class="com.action.HomeAction" method="sortOnValue">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="execAndWait">
<param name="delay">50</param>
<param name="delaySleepInterval">150</param>
</interceptor-ref>
<result name="wait">jsp/waitProcess.jsp</result>
<result name="success" type="tiles">/homePage.tiles</result>
</action>
<!-- USER MGMT ACTIONS AND MAPPINGS END-->
</package>
</struts>
##################################################################################
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<package name="util" extends="strutsSpringDemo">
<!-- UTILITIES ACTIONS AND MAPPINGS START-->
<action name="uploadFile" class="com.action.FileUploaderAction"
method="uploadFile">
<result name="success" type="tiles">/fileUpload.tiles</result>
</action>
<action name="uploadImage" class="com.action.FileUploaderAction"
method="uploadImageFile">
<interceptor-ref name="sessionCheckStack"/>
<interceptor-ref name="fileUpload">
<param name="maximumSize">2097152</param>
<param name="allowedTypes">
image/png,image/gif,image/jpeg,image/bmp
                </param>
</interceptor-ref>
<result name="input" type="tiles">/fileUpload.tiles</result>
<result name="success" type="tiles">/fileUploadSuccess.tiles</result>
</action>
<!-- UTILITIES ACTIONS AND MAPPINGS END-->
</package>
</struts>
********************************************************************************

No comments:

Post a Comment

Thanks for your comments/Suggestions.