How to call action method on page load? Below is my action method
public String **getlist**() {
myList=dao.getList();
return "success" ;
}
I want to load the data on index.jsp page by executing the getList
on page load.
How can i do that? What will be the result type
in web.xml
. Better u suggest the content type of web.xml
In index.jsp specify a javascript section. Then in this section submit the form like form1.submit() ; Here form1 is id of the form. write this code inside document.ready method of JQuery in javascript section. This will submit the form on page load and action specify in this form will we called and hit the getList() of action on page load.
$(document).ready(function(){
$(this).processRequest({
url: url
});
});
<action name="actionName" class="fullpathofClass" method="**getlist**">
<result name="success">jsp loaded</result>
</action>
In java script section add the document .ready function and apply the xml configration as the specified below to the to get the result
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.