Struts Quick Learning Guide 02 (Internal Training Materials) - Most material comes from "Programming Jakarta Struts"

xiaoxiao2021-03-06  39

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

org.apache.struts.Action.ActionServlet

config

/web-inf/struts-config.xml

Host

localhost

port

7001

controller

*. do

/web-inf/struts-html.tld

/web-inf/struts-html.tld

/web-inf/struts-bean.tld

/web-inf/struts-bean.tld

/web-inf/struts-logic.tld

/web-inf/struts-logic.tld

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

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

/common/404.jsp

500

/common/500.jsp

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:

Public "- // Sun microsystems, Inc.//dtd Web Application 2.3 // en"

"http://java.sun.com/dtd/web-app_2_3.dtd">

Storefront

org.apache.struts.Action.ActionServlet

config

/web-inf/struts-config.xml

debug

3

detail

3

1

Storefront

/ action / *

Index.jsp

404

/common/404.jsp

500

/common/500.jsp

/web-inf/struts-html.tld

/web-inf/struts-html.tld

/web-inf/struts-bean.tld

/web-inf/struts-bean.tld

/web-inf/struts-logic.tld

/web-inf/struts-logic.tld

1. So far, Struts' development environment installation is a paragraph.

转载请注明原文地址:https://www.9cbs.com/read-65282.html

New Post(0)