Category Archives: Struts2

Struts2 Ajax Validation

AJAX validation in Struts 2 is performed by jsonValidation interceptor. It is not found in the default stack so we need to define it explicitly. It doesn’t perform any validation itself that is why it must be used with validation interceptor. It is found in the jsonValidationWorkflowStack, that includes jsonValidation, validation and workflow interceptors and basicstack.

To use the AJAX validation, you need to add dojo plugin in your project.
Let’s create an example registration form.
Read more

Struts2 Multiple Configuration File

In Struts 2 we can create multiple configuration xml file. The idea is to create multiple configuration file is for better management of the application.

We must have one struts.xml file. Then we can add several files in struts.xml in include sub-element of struts element.

1. JSP View Pages

index.jsp

  <a href="hello">root namespace</a>|
  <a href="first/hello">first namespace</a>|
  <a href="second/hello">second namespace</a>

Read more

Struts2 Multiple Namespace

We can handle multiple modules by given a namespace to each module in struts.xml file by the namespace attribute of package element. Default namespace is / (root).
Here is an example where we will define multiple namespaces in struts.xml file.

1. JSP View Pages

index.jsp

  <a href="hello">root namespace</a>|
  <a href="first/hello">first namespace</a>|
  <a href="second/hello">second namespace</a>

Read more

Struts2 Introduction

What is Struts2?

The struts 2 framework is an elegant and extensible framework for creating MVC-based web application initially created by Craig McClanahan and donated to Apache Foundation in May, 2000 and Struts 1.0 was released in June 2001.

The current stable release of Struts is Struts 2.3.24 was released in 7 May 2015.
Struts 2 is the combination of webwork framework of opensymphony and struts 1.
struts2 = webwork + struts1

The Struts 2 provides supports to POJO based actions, Validation Support, AJAX Support, Integration support to various frameworks such as Hibernate, Spring, Tiles etc, support to various result types such as Freemarker, Velocity, JSP etc.
Read more