In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the common settings in the web.xml element of what the relevant knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe you read this web.xml element in the common settings of which articles will be rewarded, let's take a look.
Introduction to web.xml element
There is a web.xml configuration file under the WEB-INF of each station, which provides the configuration settings of our platform.
Web.xml element definition:
Name and description of ◆ platform
◆ does initialization for environment parameters (Context)
Name and mapping of ◆ Servlet
Settings for ◆ Session
The contrast of ◆ Tag library
◆ JSP Web Page Settings
◆ Mime Type processing
◆ error handling
◆ uses JDNI to obtain platform Resources
To understand the setting value of web.xml, you must understand its schema. Know from web.xml that its schema is customized by Sum Microsystems. If you want to learn more about it, you can go to this page, where there is a more detailed introduction. Here I would like to introduce what we usually see the most.
< ?xml version="1.0" encoding="ISO-8859-1"?> < web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://cache.yisu.com/upload/information/20210521/332/501654< /small-icon>The small-icon element should point to the path of a small icon in the web site with a size of 16 X 16 pixel, but the image file must be in GIF or JPEG format and the extension must be .gif or .jpg.
< large-icon>/ path / largeicon-jpg
< /large-icon>The large-icon element should point to a large chart path in the web site with a size of 32 X 32 pixel, but the image file must be in GIF or JPEG format and the extension must be; gif or jpg. Example:
< display-name>Develop Example
< /display-name> < description>JSP 2.0 Tech Book's Examples
< /description> < icon> < small-icon>/ images/small.gif
< /small-icon> < large-icon>/ images/large.gir
< /large-icon> < /icon> < distributable>Distributable element is an empty tag, whether it exists or not can specify whether the site can be distributed or not. If this element appears in the web.xml, it means that the site has already been developed
It is designed to be able to be executed across multiple JSP Container.
< context-param>The context-param element is used to set the environment parameters (context) of the web site, which contains two child elements:
Param-name and param-value.
< param-name>Parameter name
< /param-name>Set the Context name
< param-value>Value
< /param-value>Set the value of the Context name
Example:
< context-param> < param-name>Param_name
< /param-name> < param-value>Param_value
< /param-value> < /context-param>The parameters you set can be obtained in the JSP page by using the following methods:
${initParam.param_name}
In Servlet, you can use the following methods to obtain:
String param_name=getServletContext () .getInitParamter (param_name)
< filter>The filter element is used to declare settings related to filter. The filter element, in addition to the child elements described below, includes
< servlet>Introduced.
< icon> < display-name> < description> < init-param>It is used for the same purpose.
< filter-name>The name of the Filter
< /filter-name>Defines the name of the Filter.
< filter-class>Class name of the Filter
< /filter-class>The class name that defines the Filter. For example: com.foo.hello
Example:
< filter> < filter-name>SetCharacterEncoding
< /filter-name> < filter-class>Coreservlet.javaworld.CH11.SetCharacterEncodingFilter
< /filter-class> < init-param> < param-name>Encoding
< /param-name> < param-value>GB2312
< /param-value> < /init-param> < /filter> < filter-mapping>The two main child elements of filter-mapping element are filter-name and url-pattern. It is used to define the URL corresponding to Filter.
< filter-name>The name of the Filter
< /filter-name>Defines the name of the Filter.
< url-pattern>URL
< /url-pattern>The RUL corresponding to Filter. For example:
< url-pattern>/ Filter/Hello
< /url-pattern> < servlet-name>The name of the Servlet
< servlet-name>Defines the name of the servlet.
< dispatcher>REQUEST | INCLUDE | FORWARD | ERROR
< /disaptcher>Set the request method corresponding to Filter. There are four kinds of RQUEST,INCLUDE,FORWAR,ERROR. The default is REQUEST.
Example:
< filter-mapping> < filter-name>GZIPEncoding
< /filter-name> < url-pattern>/ *
< /url-pattern> < /filter-mapping> < listener>The listener element is used to define the Listener interface, and its main child elements are
< listener-class> < listen-class>Class name of the Listener
< /listener-class>The class name that defines the Listener. For example: com.foo.hello
Example:
< listener> < listener-class>Coreservlet.javaworld.CH11.ContenxtListener
< /listener-class> < /listener> < servlet-mapping>The servlet-mapping element contains two child elements, servlet-name and url-pattern. It is used to define the URL corresponding to servlet.
< servlet-name>The name of the Servlet
< /servlet-name>Defines the name of the Servlet.
< url-pattern>Servlet URL
< /url-pattern>Define the RUL corresponding to Servlet. For example:
< url-pattern>/ Servlet/Hello
< /url-pattern>Example:
< servlet-mapping> < servlet-name>LoginChecker
< /servlet-name> < url-pattern>/ LoginChecker
< /url-pattern> < /servlet-mapping> < session-config>Session-config contains a child element session-timeout. Define the session parameters in the web site.
< session-timeout>Minute
< /session-timeout>Define the validity period of all session on this web site. The unit is minutes.
Example:
< session-config> < session-timeout>twenty
< /session-timeout> < /session-config> < mima-mapping>Mime-mapping contains two child elements, extension and mime-type. Define an extension to map to a MIME Type.
< extension>Extension name
< /extension>Extended name
< mime-type>MIME format
< /mime-type>MIME format.
Example:
< mime-mapping> < extension>Doc
< /extension> < mime-type>Application/vnd.ms-word
< /mime-type> < /mime-mapping> < mime-mapping> < extension>Xls
< /extension> < mime-type>Application/vnd.ms-excel
< /mime-type> < /mime-mapping> < mime-mapping> < extension>Ppt
< /extesnion> < mime-type>Application/vnd.ms-powerpoint
< /mime-type> < /mime-mapping> < welcome-file-list>Welcome-file-list contains a child element welcome-file. Used to define the home list.
< welcome-file>Used to specify the name of the home file
< /welcome-flie>Welcome-file is used to specify the name of the home file. We can use
< welcome-file>Specify several home pages, and the server will find the home page in the set order.
Example:
< welcome-file-list> < welcome-file>Index.jsp
< /welcome-file> < welcome-file>Index.htm
< /welcome-file> < /welcome-file-list> < error-page>The error-page element contains three child elements, error-code,exception-type and location. Correspond to the type of error code (Error Code) or exception (Exception)
Path to web site resource.
< error-code>Error code
< /error-code>HTTP Error code, for example
< exception-type>Exception
< /exception-type>A fully named Java exception type
< location>/ path
< /location>Related resource paths within the web site
Example:
< error-page> < error-code>four hundred and four
< /error-code> < location>/ error404.jsp
< /location> < /error-page> < error-page> < exception-type>Java.lang.Exception
< /exception-type> < location>/ except.jsp
< /location> < /error-page> < jsp-config>The jsp-config element is mainly used to set the relevant configuration of JSP.
< jsp:config>Include
< taglib>And
< jsp-property-group>Two child elements. Among them
< taglib>element
It already exists at JSP 1.2; and
< jsp-property-group>Is a new element in JSP 2.0.
< taglib>The taglib element contains two child elements, taglib-uri and taglib-location. Used to set the Tag Library path used by JSP pages.
< taglib-uri>URI
< /taglib-uri>Taglib-uri the taglib instruction of the URI,JSP page that defines the TLD file can access the TLD file through this URI.
< taglib-location>/ WEB-INF/lib/xxx.tld
< /taglib-laction>The TLD file corresponds to the location of the Web site.
< jsp-property-group>The jsp-property-group element contains eight elements, which are:
< description>Description
< /descrition>Description of this setting
< display-name>Name
< /display-name>The name of this setting
< url-pattern>URL
< /url-pattern>Set the range of values affected, such as / CH2 or / * .jsp
< el-ignored>True | false
< /el-ignored>If true, the EL syntax is not supported.
< scripting-invalid>True | false
< /scripting-invalid>If it is true, it does not support
< %scription%>Grammar.
< page-encoding>Encoding
< /page-encoding>Set the encoding of JSP web pages
< include-prelude>.jspf
< /include-prelude>Set the header of the JSP page with a .jspf extension
< include-coda>.jspf
< /include-coda>Sets the end of the JSP page with a .jspf extension
Example:
< jsp-config> < taglib> < taglib-uri>Taglib
< /taglib-uri> < taglib-location>/ WEB-INF/tlds/MyTaglib.tld
< /taglib-location> < /taglib> < jsp-property-group> < description>Special property group for JSP Configuration JSP example.
< /description> < display-name>JSPConfiguration
< /display-name> < uri-pattern>/ *
< /uri-pattern> < el-ignored>True
< /el-ignored> < page-encoding>GB2312
< /page-encoding> < scripting-inivalid>True
< /scripting-inivalid>.
< /jsp-property-group> < /jsp-config> < resource-ref>The resource-ref element consists of five child elements, description,res-ref-name,res-type,res-auth,res-sharing-scope. Use JNDI to obtain platform available resources.
< description>Description
< /description>Resource description
< rec-ref-name>Resource name
< /rec-ref-name>Resource name
< res-type>Types of resources
< /res-type>Types of resources
< res-auth>Application | Container
< /res-auth>Resources are licensed by Application or Container
< res-sharing-scope>Shareable | Unshareable
< /res-sharing-scope>Whether resources can be shared. The default value is Shareable
Example:
< resource-ref> < description>JNDI JDBC DataSource of JSPBook
< /description> < res-ref-name>Jdbc/sample_db
< /res-ref-name> < res-type>Javax.sql.DataSoruce
< /res-type> < res-auth>Container
< /res-auth> < /resource-ref>This is the end of the article on "what are the common settings in the web.xml element?" Thank you for reading! I believe you all have a certain understanding of the knowledge of "what are the common settings in web.xml elements". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.