Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 action result

 
Kousik Majumder
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am newbie in struts 2. I do not understand how in the below struts.xml code the dynamic value will be populated even though in the action class there is no class variable declared?
So my question is how {1} is populated?



Thanks in advance,
Kousik
 
Yogesh Lonkar
Ranch Hand
Posts: 94
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you should have a look in struts docs Here
 
khadar valli
Greenhorn
Posts: 18
Java MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have more than two action methods with almost same name , at that time , we will use wildcards......
without wildcards
<struts-config>

<action-mappings>

<action
path="/ListUserAction"
type="com.mkyong.common.action.UserAction"
parameter="ListUser"
>

<forward name="success" path="/pages/ListUser.jsp"/>

</action>

<action
path="/AddUserAction"
type="com.mkyong.common.action.UserAction"
parameter="AddUser"
>

<forward name="success" path="/pages/AddUser.jsp"/>

</action>

<action
path="/EditUserAction"
type="com.mkyong.common.action.UserAction"
parameter="EditUser"
>

<forward name="success" path="/pages/EditUser.jsp"/>

</action>

<action
path="/DeleteUserAction"
type="com.mkyong.common.action.UserAction"
parameter="DeleteUser"
>

<forward name="success" path="/pages/DeleteUser.jsp"/>

</action>


</action-mappings>

</struts-config>

with wildcards
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">

<struts-config>

<action-mappings>

<action
path="/*UserAction"
type="com.mkyong.common.action.UserAction"
parameter="{1}User"
>

<forward name="success" path="/pages/{1}User.jsp"/>

</action>

</action-mappings>

</struts-config>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic