trainingtrains Logo

91-9990449935

 0120-4256464

Struts 2 Multiple Namespace Example

We can define multiple namespaces in struts.xml file by the namespace attribute of package element. As we know, default namespace is / (root).

Let's see the simple example to define multiple namespaces in struts.xml file.

Define multiple namespaces in struts.xml

This struts.xml file contains three packages with different names and namespaces.

struts.xml

Other required resources

We need some other required files to understand the full example of multiple namespaces.

  • index.jsp
  • action class (Welcome.java)
  • 3 view components

1) Create index.jsp

This jsp page provides three links.

index.jsp

3) 3 view components

Here name of all the 3 view components are same but there location are different.

welcome.jsp

It must be located in the root directory.

welcome.jsp

It must be located in the first directory under the root directory.

welcome.jsp

It must be located in the second directory under the root directory.