Results

After action executes business logic, tag is used to display the View. Struts2 provides or supports to 11 types of Results. Result type is linked to View.

Results


Results

After action executes business logic, <result > tag is used to display the View.

Struts2 provides or supports to 11 types of Results:

  1. FreeMarker
  2. dispatcher
  3. redirect action
  4. Velocity
  5. chaining
  6. Result
  7. Redirect Result
  8. Redirect Action Result
  9. Stream Result
  10. XSL Result
  11. PlainText Result

Result types are configured within the <package> tag.

"type" attribute is used to configure an action that will execute a result. "name" attribute provides a unique identifier, "class" attribute provides the implementation class for the result type and "default" attribute allows changes in the default result type.

If no attribute is specified, default type "dispatcher" is used to dispatch to JSP pages.

One can custom create their own Result types and configure them in web application.

There are also other ways to render results:

Result type is linked to View. Besides the "type" attribute and default type "dispatcher" attribute, there are three other technologies that can replace JSPs in a Struts2 application:

  1. Velocity Templates
  2. Freemarker Templates
  3. XSLT Transformations