When using SSH, findByExample and findByAll are generated in DaoImpl.
In general, we will use findByAll in the execute method to prepare data for the page.
If this Action is included in your jsp page, data overwrites will occur.
[Html] \
<S: action name = "category" executeResult = "false"> </s: action>
<S: action name = "category" executeResult = "false"> </s: action>
Now we can directly use findByExample in the execute method.
The query method does not need to be written in execute.
Code:
[Java]
Public String execute (){
List <Category> cList = (List <Category>) categoryService. findByExample (getCategory ());
Map map = (Map) ServletActionContext. getContext (). get ("request ");
Map. put ("categorylist", cList );
System. out. println ("query object, data size:" + cList. size ());
Return "success ";
}
Public String execute (){
List <Category> cList = (List <Category>) categoryService. findByExample (getCategory ());
Map map = (Map) ServletActionContext. getContext (). get ("request ");
Map. put ("categorylist", cList );
System. out. println ("query object, data size:" + cList. size ());
Return "success ";
}
In this way, at the beginning, there were no conditions, that is, preparing all the data,
Let the input condition, which is not null according to the condition and then comes to the product SQL statement
Similar to: select * from table where name = 222... sex = 2222 ....