For Struts applications, its configuration file Web.xml should configure the ActionServlet class. In addition, the Struts tag library used by the web application. This example uses three label libraries: struts bean, struts HTML and STRUTS Logic tag library. Routines 2-7 is the source code of web.xml.
Routines 2-7 Web.xml
XML Version = "1.0" encoding = "UTF-8"?>
PUBLIC "- // Sun microsystems, Inc.//dtd Web Application 2.2 // en"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
init-param>
servlet>
servlet-maping>
welcome-file-list>
taglib>
taglib>
web-app>
Create a configuration file for the Struts framework
As mentioned earlier, the Struts framework allows applications to be divided into multiple components and increase development speed. The configuration files for the Struts framework Struts-config.xml can assemble these components and determine how to use them. Routines 2-8 are the source code for the struts-config.xml file for the HelloApp application.
Routines 2-8 Struts-Config.xml
Xml Version = "1.0" encoding = "ISO-8859-1"?>
"- // Apache Software Foundation // DTD Struts Configuration 1.1 // en"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
This is the struts configuration file for the "Hello!" Sample Application
->
form-beans>
TYPE = "Hello.HelloAction" Name = "Helloform" Scope = "request" Validate = "True" INPUT = "/Hello.jsp" > action> action-mappings> Struts-Config> The above code is configured to HelloApp's Helloform, HelloAction, and message resource files, first pass Then pass through The element is configured with an Action component: TYPE = "Hello.HelloAction" Name = "Helloform" Scope = "request" Validate = "True" INPUT = "/Hello.jsp" > action> In this example The The struts-config.xml file finally passed The element defines a resource bundle: