Monday, January 19, 2015

struts.xml sample for Struts2


<struts>

 <constant name="struts.multipart.saveDir" value="/mydomain/myapp/website/temp/"/> 
 
 <constant name="struts.devMode" value="false" />
 
 <constant name="struts.enable.SlashesInActionNames" value="true"/>
 <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
 <constant name="struts.action.extension" value="action,,mpg,mp3,gif,png,jpeg,jpg,bmp" />
 <constant name="struts.multipart.maxSize" value="10000000" />
 <!-- struts2 ssl plugin -->
 <constant name="struts2.sslplugin.httpPort" value="80"/>
 <constant name="struts2.sslplugin.httpsPort" value="443"/>
 <constant name="struts2.sslplugin.annotations" value="true"/>
 
 <package name="default" extends="struts-default">
  
  <interceptors>
   <interceptor name="clientTypeInterceptor" class="net.mydomain.myapp.interceptor.ClientTypeInterceptor"></interceptor>
   <interceptor name="ajaxInterceptor" class="net.mydomain.myapp.interceptor.AjaxInterceptor"></interceptor>
   <interceptor name="accessInterceptor" class="net.mydomain.myapp.misc.AccessInterceptor"></interceptor>
   <interceptor name="sslInterceptor"  class="net.mydomain.myapp.ssl.SSLInterceptor"/>
   
   
   <interceptor-stack name="myAjaxStack">
    <interceptor-ref name="ajaxInterceptor"/>
   </interceptor-stack>
   
   <interceptor-stack name="myDefaultStack">
    <!-- remove the following line to work with localhost -->
    <interceptor-ref name="sslInterceptor"/>
    <interceptor-ref name="clientTypeInterceptor">
     <param name="interceptorName">mobileClientInteceptor</param>              
    </interceptor-ref> 
    <interceptor-ref name="defaultStack"/> 
   </interceptor-stack>
   
   <!--  accessStack is same as myDefaultStack with  the accessInterceptor to be used by login methods -->
   <interceptor-stack name="accessStack">
    <!-- remove the following line to work with localhost -->
    <interceptor-ref name="accessInterceptor"/>
    <interceptor-ref name="sslInterceptor"/>
    <interceptor-ref name="clientTypeInterceptor">
     <param name="interceptorName">mobileClientInteceptor</param>              
    </interceptor-ref> 
    <interceptor-ref name="defaultStack"/> 
   </interceptor-stack>
     </interceptors>

  <default-interceptor-ref name="myDefaultStack"/> 
   
  <action name="clientEvent" class="net.mydomain.myapp.controller.EventController" method="clientEvent" >
   <interceptor-ref name="defaultStack"/>
   <result type="stream" name="success">
              <param name="contentType">text/plain</param>
              <param name="inputName">inputStream</param>
              <param name="contentDisposition">filename="response.txt"</param>              
            </result>
  </action>
</package>
<package name="json" namespace="/" extends="json-default">
          <action name="updateVoiceRate" 
        class="net.mydomain.myapp.controller.SettingsController" method="saveVoiceRate">
           <result type="json" name="success">
            <param name="root">jsonObject</param>
           </result>
          </action>


</package>

No comments:

Post a Comment