4, configure the label library, the label library is some component libraries comes with Struts, using the Tag-Lib in the JSP specification for everyone to use, because there is such a rich label library, making it so convenient to use Struts. Efficient.
controller servlet-name>
org.apache.struts.Action.ActionServlet servlet-class>
config param-name>
/web-inf/struts-config.xml param-value>
init-param>
Host param-name>
localhost param-value>
init-param>
port param-name>
7001 param-value>
init-param>
servlet>
controller servlet-name>
*. do url-pattern>
servlet-maping>
/web-inf/struts-html.tld taglib-uri>
/web-inf/struts-html.tld taglib-location>
taglib>
/web-inf/struts-bean.tld taglib-uri>
/web-inf/struts-bean.tld taglib-location>
taglib>
/web-inf/struts-logic.tld taglib-uri>
/web-inf/struts-logic.tld taglib-location>
taglib>
web-app>
The label library uses definition, contains two sub-elements, , and , User definition label library's unique representation, can be understood as name, afterwards This label library is used in the JSP page, which is it. Indicates the physical paths where the label library exists, of course, and the configuration files are also relative paths.
5, set a list of Welcome files (optional steps)
index.jsp welcome-file> welcome-file-list>
6, set the error handling (optional step), the usual HTTP Access exception contains 404 Not Found and 500 Internal Error, in order to provide users more friendly display, you can do the following configuration:
404 ERROR-CODE>
/common/404.jsp location>
Error-Page>
500 ERROR-CODE>
/common/500.jsp location>
Error-Page>
web-app>
By configuring, when the user accesses the page does not exist in the application, the user will guide the user to the /common/404.jsp page. Similarly, when an abnormal error occurs, /common/500.jsp is displayed to the user.
7. Finally, a complete web.xml example is as follows:
XML Version = "1.0" encoding = "UTF-8"?>
Public "- // Sun microsystems, Inc.//dtd Web Application 2.3 // en"
"http://java.sun.com/dtd/web-app_2_3.dtd">
Storefront servlet-name>
org.apache.struts.Action.ActionServlet servlet-class>
config param-name>
/web-inf/struts-config.xml param-value>
init-param>
debug param-name>
3 Param-Value>
init-param>
detail param-name>
3 Param-Value>
init-param>
1 load-on-startup>
servlet>
Storefront servlet-name>
/ action / * url-pattern>
servlet-maping>
Index.jsp welcome-file>
welcome-file-list>
404 ERROR-CODE>
/common/404.jsp location>
Error-Page>
500 ERROR-CODE>
/common/500.jsp location>
Error-Page>
/web-inf/struts-html.tld taglib-uri>
/web-inf/struts-html.tld taglib-location>
taglib>
/web-inf/struts-bean.tld taglib-uri>
/web-inf/struts-bean.tld taglib-location>
taglib>
/web-inf/struts-logic.tld taglib-uri>
/web-inf/struts-logic.tld taglib-location>
taglib>
web-app>
1. So far, Struts' development environment installation is a paragraph.