Struts 2 Configuration Files

A Struts application uses a number of configuration files. The primary two are struts.xml and struts.properties, but there can be other configuration files. For instance, a Struts plug-in comes with a struts-plugin.xml configuration file. And if you're using Velocity as your view technology, expect to have a velocity.properties file.
It is possible to have no configuration file at all. The zero configuration feature, "Zero Configuration," is for advanced developers who want to skip this mundane task.
In struts.xml you define all aspects of your application, including the actions, the interceptors that need to be called for each action, and the possible results for each action.
Interceptors and result types used in an action must be registered before they can be used. Happily, Struts configuration files support inheritance and default configuration files are included in the struts2-core- VERSION.jar file. The struts-default.xml file, one of such default configuration files, registers the default result types and interceptors. As such, you can use the default result types and interceptors without registering them in your own struts.xml file, making it cleaner and shorter. The default.properties file, packaged in the same JAR, contains settings that apply to all Struts applications. As a result, unless you need to override the default values, you don't need to have a struts.properties file.

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More