• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 - Action name works with any URL pattern

 
Brient Oh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to work on Struts 2 and stuck in the very beginning....

I'm using Strtus 2.1.6. Here is my struts.xml



I deployed my application on the Tomcat 6 and tested the following URLs;

http://localhost:8080/HelloWorld
http://localhost:8080/mypackage/HelloWorld
http://localhost:8080/foobar/HelloWorld
http://localhost:8080/foobar/HelloWorld.action

All of them work fine.... I means... they are all display /hello.jsp page.
I expected that only the first link would work; the others would be 404 error...

Even, this URL, http://localhost:8080/12312312oijwoie/HelloWorld, works!!
I think any URL pattern is working as long as the action name is matching at the end.

Any comments and solution would be very appreciated.

 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is working because of the namespace="/" part. If you read the namespace-configuration it says

A root namespace ("/") is also supported. The root is the namespace when a request directly under the context path is received. As with other namespaces, it will fall back to the default ("") namespace if a local action is not found.

So its acting like a fallback, when you write /foobar/HelloWorld, struts tries to find a HelloWorld action in foobar namespace, since none is found, so the request is sent to the HelloWorld in default namespace...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But there isn't a HelloWorld action in the default namespace.

Are you deploying the Convention plugin?

You might want to deploy the config-browser plugin to see what Struts 2 thinks your configuration space looks like.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic