File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts.xml mapping and add action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts.xml mapping and add action" Watch "Struts.xml mapping and add action" New topic

Struts.xml mapping and add action

sankar singh
Ranch Hand

Joined: Aug 17, 2007
Posts: 40
I have started to learn Struts2.0,

First Simple Program itself confusion..My Qeustion is in Struts.xml maping file we are not adding .action but request input jsp

why we should add .action apart from ActionName

Example : action="HelloWorld.action"


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>HelloWorld Struts </title>
hello world
<form name="Form1" action="HelloWorld.action">
<input type="submit" value="JustClick" name="JustClick" />

Struts.xml : Here action name is "HelloWorld",

<package name="default" extends="struts-default">
<action name="HelloWorld" class="comm.HelloWorld">
<result name="success">HelloWorld.jsp</result>

Is it must to keep .action in all the request page (action="actionName.action)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
the .action suffix is a way of communicating with the Struts 2 interceptor that you want it to look for an action defined in the struts.xml file and execute a method on it. Without the suffix, the interceptor doesn't know if you're just trying to load an image file or HTML page, or display the contents of a directory.

Consultant, Sima Solutions
sankar singh
Ranch Hand

Joined: Aug 17, 2007
Posts: 40
thanks for your answer, is there any possibility to use myown name instead of .action,

For this should i need to change any configuration file?

Sankar. S
I agree. Here's the link:
subject: Struts.xml mapping and add action
It's not a secret anymore!