Struts 2 development mode configuration

Struts 2 development mode configuration

If you are working on Struts 2 application you could use setting development mode ( devmode) true or false. When you set this property struts 2 provide extra debug and logging information which can be speed up your development because it helps to find issue.

What it does:

By default development mode is disabled when you enabled it reload resource bundle on every request. It means when you are working on development environment and changed your properties files you could see the changes in next request. It also reloads XML configuration files ex: struts.xml, validation rules files including other XML configuration files.

How can you make it enable:
You can declare it in multiple files and struts frameworks search it in following order:

  • struts-default.xml
  • struts-plugin.xml
  • struts.xml
  • struts.properties
  • web.xml

Sample settings:

  • web.xml:
<filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        <init-param>
            <param-name>struts.devMode</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>struts.custom.i18n.resources</param-name>
            <param-value>ApplicationResources</param-value>
        </init-param>               
</filter>
  • struts.xml file:
<struts>
  <constant name="struts.devMode" value="true" />
</struts>
  • struts.properties file:
struts.devMode = true

For more information please read this tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *