This class implements the ResultMapBuilder and traverses the web application content directory looking for reasonably named JSPs and other result types as well as annotations. This naming is in this form:
/resultPath/namespace/action-<result>.jsp
If there are any files in these locations than a result is created for each one and the result names is the last portion of the file name up to the . (dot).
When results are found, new ResultConfig instances are created. The result config that is created has a number of thing to be aware of:
- The result config contains the location parameter, which is required by most result classes to figure out where to find the result. In addition, the config has all the parameters from the default result-type configuration.
After loading the files in the web application, this class will then use any annotations on the action class to override what was found in the web application files. These annotations are the {@link Result}and {@link Results} annotations. These two annotations allow an actionto supply different or non-forward based results for specific return values of an action method.
The result path used by this class for locating JSPs and other such result files can be set using the Struts2 constant named struts.convention.result.path or using the {@link org.apache.struts2.convention.annotation.ResultPath}annotation.
This class will also locate and configure Results in the classpath, including velocity and FreeMarker templates inside the classpath.
All results that are configured from resources are given a type corresponding to the resources extension. The extensions and types are given in the table below:
Extension | Type |
.jsp | dispatcher |
.jspx | dispatcher |
.html | dispatcher |
.htm | dispatcher |
.vm | velocity |
.ftl | freemarker |