In general, when we use STRUTS2, we submit a form form and submit a actionname.do (action). However, we want to query when the page is loaded, how to do it?
Personal practice is as follows:
index.jsp page
<jsp:forward page= "Actionname.do" ></jsp:forward>
main.jsp page
is the page where you want to display the data
Struts2.xml Configuration
<action name= "ActionName" class= "edison.esop.action.ScreenHeaderAction" method= "linenamelist" >
< Result name= "linenamelist" >/main.jsp</result>
<result name= "Input" >/downfail.jsp</ Result>
</action>
Specifically corresponding to the action class, I will not write, write only the corresponding method
Public String linenamelist () {
...
}
The last point, using the <jsp:forward> tag, is to add the following in the Web. XML configuration file
<filter>
<filter-name>struts2</filter-name>
<filter-class>
Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</ filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern >/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>forward</ dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>error</dispatcher >
</filter-mapping>