Xiang Jie Struts configuration file, web.xml and struts-cofig.xml, as well as the struts-cofig.xml in the role of the various labels
Web application deployment descriptor file: web application deployment descriptor file can be open in the application of those who, publishers, and assembly to pass configuration information between, Web container, when you start to read from the file configuration information, according to it to load and configure the web application. document type setting
Yi DTD for XML documents to define the format, DTD bar XML document is divided into elements, attributes, entities, each has its own XML document's DTD file. Can be downloaded from the Internet. <web-app> Element is web.xml of the the root element, other elements must be embedded within the element in the <web-app>. to
Note that the order of child elements also have such must be the first <servlet>, then <servlet-mapping> last <taglib>.
Web.xml for the Struts application configuration file: The first and most important step is to configure the ActionServlet, the use <servlet> tag servlet-name attribute name from an action, then use the servlet-class attribute specifies the ActionServlet class. Ran
Later <servlet-mapping> tag servlet-name attribute specifies the action, using url-pattern range is designated to receive *. do requests. Regardless of the application contains a number of sub-applications, only need to configure a ActionServlet, class to come out application of the different functions
In fact, those who are unnecessary, because the Servlet itself is multi-threaded, and is currently only allows Struts to configure a ActionServlet. Declaration ActionServlet initialization parameters: <servlet> the <init-param> sub-elements used to configure the initial Servlet the beginning of Participation
A few. Param-name set the config parameter names. Param-value set the struts-config.xml path parameter values.
Welcome to the list of configuration: If the client access when the value of Web access to the root directory of the WEB application URL. There is no specific designated documents, Web will automatically call the Web a welcome file. <welcome-file-list> Element configuration. Through where <welcome -
file> Welcome Page </ welcome-file> to configure.
Configuration error handling: Although the Struts framework for a powerful error-handling mechanism, but can not guarantee to handle all of the error or exception. When an error occurs, if the frame can not handle this error, the wrong to abandon to the Web container, in the case of default web container will want to
The client returns an error message. If you want to avoid letting customers see the original error message, you can file in the Web application deployment descriptor to configure <error-page> element. <error-code> 404 defined by the type of error. Then " location> to deal with error JSP page to
Of error processing. <exception-type> Can also be used to set up an exception, and then <location> to handle exception JSP page to handle exceptions.
Configure the Struts tag library: This is learned on the previous JSP custom tags similar <taglib> configuration elements to configure. <taglib-uri> The specified tag library uri, similar to a name from. <taglib-location> This is the tag library location is real
Where the path of the occasion. Through this method is introduced into a tag library, and then in front JSP pages can be defined through their own URI to call the label.
Struts configuration file: struts-config.xml file. First of all discussions about org.apache.struts.config package, in the struts application startup will read the Struts configuration file information into memory and to store them in the config package-related The
JavaBean instance of the class. Package for each class, and a struts configuration file corresponds to a specific configuration elements, ModuleConfig in the Struts framework played a very important role, which is the core of the whole config package, at run time to store the Struts the configuration of the entire application
Information. If you have multiple sub-applications, there will be a ModuleConfig object, it and the Struts file corresponds to the root element of <struts-config>. The root element that contains elements such as <form-bean> <action> <forward>.
<struts-config> elements: Struts configuration file when the root element, and its corresponding configuration class ModuleConfig class, <struts-config> element has eight sub-elements. Their DTD is defined as data-sources? form-bean? global - exception?
global-forwards? action-mapping? controller? message-resources? plug-in * in the Struts configuration file, you must firstly according to DTD specified in the order to configure the various sub-elements <struts-config> element, if the reversal of these sub-elements of order,
Will produce an error.
<data-sources> elements: used to configure the application of the required data sources, data source is responsible for creating and specific database. many of the data source connection pooling mechanism used to achieve. in order to improve the performance of database access. JAVA language provides a
javax.sql.DataSource interface, all of the data source must implement this interface. many application server and Web server provides a data source component. Many database vendors also provide the data source implementation. <data-sources> element contains more than a <data-source> sub -
Element is always configure a specific data source. <set-property> They can contain multiple sub-elements used to set the various properties of the data source. After the data source is configured, you can access the data in the Action class in the source is defined in the Action the getDataSource (HttpRequest) square
Method used to obtain the data source object. And then can use the DataSource object to call getConnection to obtain a connection object to the database to operate. In a statement in the configuration file when the need for multiple data sources for each data source assigned a unique Key values , through this
One to represent a particular data source. To obtain specific data sources can be used when the dataSource = getDataSource (reqeust, "A");
<form-beans> elements: used to configure the number of ActionForm, contain one or sub-element of N a <form-bean>. Each <form-bean> element contains multiple attributes. className specify and match <form-bean> class. name only to specify the ActionForm
Identifier, this property is necessary to use as future reference. Type specified ActionForm class full class name, this property is also necessary. Note that package names should add. <form-property> Is designated Form dynamic elements, after the would know better.
<global-exception> elements: used to configure exception handling, the element can contain one or more <exception> element, is used to set the JAVA exceptions and exception handling classes ExceptionHandler mapping between. className and elements corresponding to the configuration of the specified class,
The default do not move. Handler class specified default ExceptionHandler.key exception handling in the local resource file in the specified exception message Key, path specify the current exception occurs when the forwarding path. Scope specifies the scope of ActionMessages instance storage. Type specified
Need to address the exception class name, required. Bundle designated Resource Bundle.
<global-forwards> elements: used to declare global forward, the element can have one or N a <forward> elements, used to a logical name mapped to a specific URL, through this method Action class or JSP pages without specifying the URL , as long as the specified logical name
That can be achieved, or redirect the request forwarding. This can reduce the control components and view aggregate. Easy to maintain. ClassName corresponding to the configuration of classes. ContextRelative if it is true that when the path attribute to / at the beginning of time, given that the corresponding The default is the context URL
false.name forwarding path of logic, it must write. path forwarding or redirect URL, must be written to be based on / at the beginning. redirect set to true when the operation said the implementation of the redirect, this is false when the execution of the request that forwarding operations. redirection and forwarding the request
The difference is that after the redirect is to generate the response to the client request and then re-sent to the orientation of the URL, the browser address bar will be displayed. Which is transmitted directly to the request transmitted to the application of another file, it does not generate the response IE did not show the client.
<action-mapping> elements: contain one or N a <action> elements, describes the path from a specific request to respond to the mapping of the Action. in the <action> element can contain multiple sub-elements <exception> and <forward> They were different configurations of local
Regular treatment and local forwarding. Attribute set the Action associated with the ActionForm in the request or the session within the key. Is shared within the request or the session name. ClassName the class corresponding to configuration elements. The default is ActionMapping.forward
URL forwarding path to include the specified URL path to the specified included. Input form that contains the specified URL, when the form validation fails when sent URL.name, and the Action associated with the specified Form name. The name must be defined in the form-bean before, it may write may from time to write. path must be
To be / at the beginning of the path of Action of the position. Parameter configuration parameters specified Action. In the Action's execute () method can be called ActionMapping the getParameter () method to read the match parameter. Roles allowed to invoke the Action specified security role, a number of
The role of a comma between the open cell. Scope specifies the scope of Form presence. Session.tyep the specified default is the complete Action class name. Unknown if it is true that the user can handle all of the issued invalid ActionURL default false.validate specify whether you call
ActionForm's validate method.
<controller> elements: used to upload files to configure ActionServlet.buffreSize specify the size of the input buffer. 4096.className the property is optional default configuration of the specified element in the corresponding class, ControllerConfig. and then specify the ring contentType
The results should be the content type and character encoding, the attribute is optional, default is text / html If Action or JSP pages can also set the type of content will be covered by this. Locale specifies whether to save the Locale object to the current user's session default false . tempDir specified
Handling file upload a temporary working directory. Nochache If this is true in response to the results of the first to add a specific parameter.
<message-resources> elements: used to configure the Resource Bundle. used to store a local text message file. className element in the configuration of the corresponding class. MessageResourcesConfig.factory specified message factory class. key stored in the specified file
Servlet object attributes used in Key.null specify how to handle the unknown message. Parameter specifies the message file name.
<plug-in> elements: used to configure Struts plug-in.
Configure multi-application modules: all the sub-applications can share the same one ActionServlet instance, but each sub-application has a separate configuration file. The application is divided into multiple sub-application module. First, for each application to create a separate Struts configuration file, in the web.xml of
ActionServlet configuration code to add a few sub-applications information. <forward> Elements used to implement switching between applications.
Digester component: It is an Apache open-source project to another. When Struts is initialized, the first will be read and parse the configuration file, the framework and the use of Digester component to the West configuration file. And then create a config package object. who object used to store
In fact, the configuration file is not difficult, as long as the principles of which are reasonable on OK. Real real project development, using tools such as Eclipse series, provides the corresponding plug-in project to create a Struts configuration file when the labels are automatically generated, and we
Only need to fill attribute puts inside OK.
Related Posts of Xiang Jie Struts configuration file, web.xml and struts-cofig.xml, as well as the struts-cofig.xml in the role of the various labels
Xiang Jie Struts configuration file, web.xml and struts-cofig.xml, as well as the struts-cofig.xml in the role of the various labels
Struts applications use two XML-based configuration files to configure, respectively web.xml and struts-cofig.xml file. Web.xml file is the configuration for all web applications, while the struts-config.xml file is struts-specific configuration files, In
Struts.xml as a very important struts2 a configuration file, master that he is for the flexible use of struts of great benefit. This article I'm going to struts2 in the configuration file for the great detail to analyze it again. First, starting
1, the minimum configuration java Code: <servlet> <servlet-name> dwr-invoker </ servlet-name> <servlet-class> uk.ltd.getahead.dwr.DWRServlet </ servlet-class> </ servlet> <servlet-mapping> <servlet-name> ...
A Java Web application configuration files: web.xml the application web.xml file is located in WEB-INF directory, and provides a WEB application configuration information. A relatively complete web.xml file is as follows: <? xml version = "1. ...
Package by manually adding Struts to develop J2EE projects, but only to find that the default can not use Struts Struts configuration editor to open the file, double-click open the Struts configuration file, the error, picture is as follows: See "org
Package by manually adding Struts to develop J2EE projects, but only to find you can not use the default Struts Struts Configuration Editor to open the file, double-click open the Struts configuration file to an error, the picture is as follows: See
With MyEclipse struts config editor editor to edit Struts configuration file error: org.eclipse.ui.PartInitException: Project fuNan_eAdmin is not configured as a MyEclipse Web-Struts Project. Therefore the MyEclipse Struts Editor may not be used with stru
<zt> http://blog.csdn.net/FutureInHands/archive/2006/11/15/1385681.aspx Struts framework reads when it starts its configuration file, according to it to create and configure the various Struts components. Struts configuration file allows developers
web.xml is the web application loads the important information about servlet configuration file, play initialization servlet, filter, etc. The role of web programs. In general, all of the MVC framework for Web applications need to load a core control ...
Struts struts-config.xml is the core file, which can be configured to a variety of components. A simple struts-config.xml file <? Xml version = "1.0" encoding = "UTF-8"?> <! DOCTYPE Struts-config PUBLIC "- / / Apache