The ssh framework summarizes three methods of receiving parameters for action, namely, receiving parameters for ssh.
Three methods for passing parameters to an action on the page
First, pass the value through the attribute:
Make sure that the property values of the page and action are the same. Write the set and get methods of the property on the action, so that when you submit parameters on the page, action will call the set Method to pass the parameter value to its attribute. This method is mainly applicable when there are few parameters passed!
Second, pass the value through DomainModel:
The DomainModel is a domain model that uses the domain object in the model layer to receive parameters.
The action Code is as follows:
// Use DomainModel to pass the value
Private FactoryMsg factorymsg;
Public FactoryMsg getFactorymsg (){
Return factorymsg;
}
Public void setFactorymsg (FactoryMsg factorymsg ){
This. factorymsg = factorymsg;
}
Jsp
Name: <input id = "factorymsg. name" name = "factorymsg. name" type = "text" maxlength = "10"/>
Price: <input id = "factorymsg. buy" name = "factorymsg. buy" type = "text" maxlength = "10"/>
Third, pass the value through ModelDriven:
Action must implement the ModelDriven interface and override the getModel () method. The example is as follows:
The action Code is as follows (no get or set method is required ):
// Use DriverModel to pass the value
Public class IndexInfoAction extends ActionSupport implementsModelDriven <LineMsg>
{
Private LineMsg linemsg = new LineMsg ();
Public LineMsg getModel (){
Return linemsg;
}
}
The id name must be the same as the attribute name of the model layer.
Name: <input id = "name" name = "name" type = "text" maxlength = "10"/> <br/>
Price: <input id = "buy" name = "buy" type = "text" maxlength = "10"/> <br/>