• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why the .action extension in required in struts2?

 
sarada bokka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"shasha ch", please check your private messages for an important administrative matter.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My question is about why only for the first request .action is required?

I guess David gave the answer
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't have anything to do with it being the *first* request, though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic