Fork me on GitHub
<< back to Core Developers Guide Edit on GitHub

Development Mode (aka “devMode”)

Please turn this option off before deploying application to a production environment - it can expose sensitive data of your application!

Struts 2 has a setting (which can be set to true or false in default.properties) called devMode (= development mode). When this setting is enabled, Struts 2 will provide additional logging and debug information, which can significantly speed up development.

You can also set this constant in your struts.xml file: <constant name="struts.devMode" value="true" />.

This is the preferred method. See Constant Configuration for more information.

What does it do?

Don’t forget…

By default, the development mode is disabled, because it has a significant impact on performance, since the entire configuration will be reloaded on every request.

Page rendering is slow

If you experience slow page rendering when devMode is on it’s mostly because Freemarker cache is disabled during devMode. You can explicit enable cache and any other options disabled by devMode, see example below:

<constant name="struts.devMode" value="true" />
<constant name="struts.i18n.reload" value="false"/>
<constant name="struts.configuration.xml.reload" value="false"/>
<constant name="struts.freemarker.templatesCache" value="true"/>
<constant name="struts.freemarker.templatesCache.updateDelay" value="120"/>
<constant name="struts.freemarker.mru.max.strong.size" value="120"/>

As you can see, you can switch devMode on and still have production options on as well.

Please remember to use production optimized options which can be different than these used during development (especially cache related)!