What are the contents of web.xml and struts-config.xml?
- The web.xml file contains the information that is used by servlets and JSPs.
- The file includes the description of the application, information about servlets, mapping information for servlets and URL, JSP configuration information, error page information that is displayed without handling exceptions, mapping information about servlets.
- The struts-config.xml file contains information about struts framework at the time of deploying the web application.
- This file includes information about form bean, action mappings, controller information that includes buffer size, forward pattern, content type, locale, class name, content forward etc.
What are the contents of web.xml and struts-config.xml?
Web.xml example :<web-app>
<servlet>
<servlet-name> XYZ </servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name> CONFIG </param-name>
<param-value>/WEB-INF/struts-config.xml </param-value>
</init-param>
<init-param>
<param-name>host </param-name>
<param-value>localhost </param-value>
</init-param>
<init-param>
<param-name>port</param-name>
<param-value>1111</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name> XYZ </servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
- Important attributes and elements of ActionMapping entry in struts-config.xml are:
- Path
- Type
- Name
- Scope
- Validate
- Input
- Forward