wood burning stoves*
The moose likes Struts and the fly likes How to invoke default and root namespaces? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to invoke default and root namespaces?" Watch "How to invoke default and root namespaces?" New topic
Author

How to invoke default and root namespaces?

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
this is my namespace file


if i put http://localhost:8080/My/abc/Struts2HelloWorld.action it goes to first namespace.
How to invoke 2 nd and 3 rd namespaces?
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Actions in a package with the default namespace will be considered only if the requested action is not found in a package with a namespace matching that of the request (didn't we already cover this? - see http://www.coderanch.com/t/485083/Struts/Application-Frameworks/are-these-both-root-tags).

In your case, mypackage3 uses the default namespace. What would happen if you browsed to http://localhost:8080/My/foobar/moo
Do you have a package which matches the namespace foobar? If not, then the framework will search the packages which use the default namespace (mypackage3 in your case).

Does that answer your question?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
then when is to invok namespace="/" ?
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Samanthi perera wrote:then when is to invok namespace="/" ?

I'm sorry, I'm not sure I can understand your English.
http://localhost:8080/My/moo would match the action in mypackage2
http://localhost:8080/My/foo/moo would not match the action in mypackage2 because the request references a namespace of foo

I think you're not seeing the difference between the / namespace and the default namespace. They are different. See the discussion we had on the previous thread (referenced above).
 
wood burning stoves
 
subject: How to invoke default and root namespaces?
 
Similar Threads
Struts2-json plugin not serializing action class to json
are these both root tags
Struts 2.1 Need two different success results
test.jsp error HTTP 500
New to Struts 2 framework