Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Why the .action extension in required in struts2? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Why the .action extension in required in struts2?" Watch "Why the .action extension in required in struts2?" New topic
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: 60785
    
  65

"shasha ch", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

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

It doesn't have anything to do with it being the *first* request, though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why the .action extension in required in struts2?
 
Similar Threads
Errr: requested resource xxxx.action is not available
JSP source
New to struts
Action.saveMessages
Action.getLocale( HttpServletRequest)