<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
The above code was automatically generated by my IDE when I choose struts framework for my project. I don't see any servlet named action . Please explain what this xml means?
EDIT :
I read that ActionServlet has been configured with the struts-config.xml file. How it is configured ?
<struts-config>
<form-beans>
<form-bean name="HelloWorldActionForm"
type="com.vaannila.HelloWorldActionForm"/>
<action-mappings>
<action input="/index.jsp" name="HelloWorldActionForm" path="/HelloWorld" scope="session" type="com.vaannila.HelloWorldAction">
<forward name="success" path="/helloWorld.jsp" />
</action>
</action-mappings>
The configuration file shown says this:
.do
will be processed by a servlet named action
action
corresponds to the class org.apache.struts.action.ActionServlet
ActionServlet
was configured in web.xml
, whereas in struts-config.xml
the different ActionForm
s get configured; implicitly these use the ActionServlet
- Óscar López 2012-04-04 13:44
Here is how Struts works:
Struts has a FrontController. This means all request are going through this controller. This is the org.apache.struts.action.ActionServlet. This class is using the struts-config to pass the request to an other class.
You have specified that everytime the URL: /HelloWorld is request the ActionServlet is passing the request to the class com.vaannila.HelloWorldAction When your class is returning success the ActionServlet will display the jsp: helloWorld.jsp