Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts.xml mapping and add action

 
sankar singh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"

input.jsp

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

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

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

Is it must to keep .action in all the request page (action="actionName.action)
------
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sankar singh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Regards,
Sankar. S
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic