File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts 2 Namespaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 Namespaces" Watch "Struts 2 Namespaces" New topic

Struts 2 Namespaces

Jeff Shelley
Ranch Hand

Joined: May 21, 2003
Posts: 70
Hello and thanks in advance for considering my question.

The concept of namespaces in struts seems pretty nice as far as logically separating groups of urls/action mappings, but it leaves me with a couple questions:

1.) I noticed that if I don't begin a context with a "/" (in the <s:url> tag), it will ADD this namespace to my url. So if I'm in the result page from http://localhost:8080/webapp/ns1/abc.action, and do <s:url action="Yo" namespace="hi"... that will give me a url of http://localhost:8080/webapp/ns1/hi/Yo.action. Is there any practical application to these nested links, or should I just always remember the slash?

2.) I'm also mapping my ajax calls in my struts.xml. Is there any word on putting these in their own namespace, or is that overkill?

Thanks very much. I look forward to reading your book.
--Jeff Shelley

It's almost Friday
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 467
As for your first question, I guess that you have to always remember the slash, since some people would like to include a name space withing another one. Of course you can extend the tag library to override this (that's the beauty of open source).

As for the second question, why don't you put the ajax calls in a separate XML file and include it in struts.xml?

Visit my blog:
I agree. Here's the link:
subject: Struts 2 Namespaces