Author
Why the .action extension in required in struts2?
sarada bokka
Ranch Hand
Joined: Jan 13, 2010
Posts: 80
Hi all,
I have been observed that for the very first request .action is required (ex: <META HTTP-EQUIV="Refresh" CONTENT="0;URL=sampleAction.action ">)
Can anyone explain me why only for the first request .action extension is required?
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56543
"shasha ch", please check your private messages for an important administrative matter.
[Smart Questions ] [JSP FAQ ] [Books by Bear ] [Bear's FrontMan ] [About Bear ]
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Jan 14, 2010 05:23:58
0
Because in that example the request is being made from an HTML page, outside of the Struts 2 application. Without the extension (by default, anyway) the container wouldn't know it was a Struts 2 action request.
Johannes Geppert
Ranch Hand
Joined: Jan 12, 2010
Posts: 67
You dont need to use action, you can edit your extension in the struts2.xml
Default is
<constant name="struts.action.extension" value="action" />
But you can use anything
<constant name="struts.action.extension" value="html" />
With the rest plugin you can use Struts2 with rest based URLs
without an extension.
Best Regards
Johannes Geppert
My Java and Webprogramming Blog
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Jan 14, 2010 07:48:38
0
You don't actually need the REST plugin for extension-less actions, though.
The default extension mapping in Struts 2.1+ is "action,,", meaning extensionless actions are supported out-of-the-box.
sarada bokka
Ranch Hand
Joined: Jan 13, 2010
Posts: 80
My question is about why only for the first request .action is required?
I guess David gave the answer
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Jan 14, 2010 18:59:59
0
It doesn't have anything to do with it being the *first* request, though.
subject: Why the .action extension in required in struts2?