What are best practices to follow while developing Struts2 application?

Answer

Some of the best practices while developing Struts2 application are:

  1. Always try to extend struts-default package while creating your package to avoid code redundancy in configuring interceptors.
  2. For common tasks across the application, such as logging request params, try to use interceptors.
  3. Always keep action classes java bean properties in a separate bean for code reuse and implement ModelDriven interface.
  4. If you have custom interceptor that you will use in multiple actions, create interceptor stack for that and then use it.
  5. Try to divide your application in different modules with namespace configuration based on functional areas.
  6. Try to use Struts2 tags in result pages for code clarify, if needed create your own type converters.
  7. Use development mode for faster development, however make sure production code doesn’t run in dev mode.
  8. Use Struts2 i18n support for resource bundles and to support localization.
  9. Struts2 provides a lot of places where you can have resource bundles but try to keep one global resource bundle and one for action class to avoid confusion.
  10. struts-default package configures all the interceptors and creates different interceptor stacks. Try to use only what is needed, for example if you don’t have localization requirement, you can avoid i18n interceptor.

All struts2 Questions

Ask your interview questions on struts2

Write Your comment or Questions if you want the answers on struts2 from struts2 Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---