Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should all action classes be listed in struts.xml

Tags:

java

struts2

Should all action classes be listed in struts.xml? Can the struts2 framework be aware of action classes if they are not listed in struts.xml?

Background: I am relatively new to struts and have been asked to cleanup some struts2 code. There are some classes that are not referred in struts2.xml, any jsp or javascript (I did a string search). I was wondering if I could remove these.

EDIT: I am pretty sure these classes are not used by other Java classes/libraries. It is the struts part I was wondering about.

like image 758
sengs Avatar asked Mar 04 '26 12:03

sengs


1 Answers

In order to be used in their intended form as a web action, one of the following four possibilities must be true:

  1. The class is listed in the struts.xml
  2. The class is annotated with struts annotations
  3. The class is inherited by another action class
  4. Your project is using the convention plugin, as mentioned by @Christina

If the class you are looking at is not in struts.xml, is not annotated, is not referenced anywhere else in the project, and the project has not included the convention plugin, you should be good to go.

The only other gotcha would be to look for other *.xml files. struts.xml is capable of including other xml files into it, so that the actual action configuration for this class may reside in a different xml file.

like image 165
Dustin Wilhelmi Avatar answered Mar 06 '26 00:03

Dustin Wilhelmi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!