I want to pass a value in action when it is called using struts1 configuration file. I have create a form bean with following property
public class MyForm ex
Struts 1.3 DTD says
The "set-property" element is especially useful when a custom subclass is used with , , , or elements.
Create Subclass of ActionMapping with properties you would like to inclide
public class CustomActionMapping extends ActionMapping {
private String task;
public String getTask() {
return task;
}
public void setTask(String task) {
this.task = task;
}
}
configure the custom action mapping in struts-config.xml
<action-mappings type="CustomActionMapping">
<action path="/myAction" name="myForm" type="demo.MyAction" scope="request">
<set-property value="view" property="task" />
<forward name="success" path="/result.jsp"></forward>
</action>
</action-mappings>
get the value of task in doGet/doPost
method your Action
class
CustomActionMapping cam = (CustomActionMapping) mapping;
String task = cam.getTask();
hope this helps you.
Does your struts-config.xml follow the schema? See sample on http://struts.apache.org/1.3.10/index.html