Programming Thoughts
Struts 2 - Annotation-based Validation
Example

Actually reducing Struts 2's arcane configuration

Struts 2 is a popular MVC framework for Java-based web applications but its annotation-based validation doesn't properly work. So, an alternative was created. This article describes a working example.

Live example

A demonstration application can be accessed here. The start page looks like the following. It allows editing of the last ten UK Prime Ministers (but changes aren't saved to disk).

Figure 1: Starting page

Download

Source code of annotation-based validation as a library can be downloaded here and a demonstration application can be downloaded here as zip files. They require the following.

  • JDK 8 or better
  • Maven 3
  • Jakarta EE server, such as Tomcat 9

First, extract the Struts Commons files and run mvn, which will install name.matthewgreet/struts-commons-1.5.0.jar in your local repository. Then extract the Example 8 files and run mvn, which compiles into example8.war. Copy that into your Jakarta server run the /example8 URL.

Next part

Continued in Alternate Redesign.