Programming Thoughts
Struts 2 - Annotation-based Validation
Form Formatting 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 then redesigned. This article describes a working example.

Live example

A demonstration application can be accessed here. The start page looks like the following. It is like example 8 but replaces formatted/unformatted field pairs with just the unformatted field. It has alternate editing pages using day, month and year dropdowns for dates.

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.6.4.jar in your local repository. Then extract the Example 10 files and run mvn, which compiles into example10.war. Copy that into your Jakarta server run the /example9 URL.