TOMCAT Web. XML Finishing Instructions

Source: Internet
Author: User

Javaweb project, Web. XML for the basic configuration of the servlet:

We note that there is also a Web. xml file in Conf under Tomcat, and yes, all of the Javaweb projects are inherited from Web. XML from the server.

Take a look at this web. xml:

[HTML]View PlainCopy
  1. <? XML version= "1.0" encoding="iso-8859-1"?>
  2. <Web-app xmlns="Http://java.sun.com/xml/ns/javaee"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee
  5. Http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd "
  6. version="3.0">
  7. <servlet>
  8. <servlet-name>default</servlet-name>
  9. <servlet-class>org.apache.catalina.servlets.defaultservlet</servlet-class >
  10. <init-param>
  11. <param-name>debug</param-name>
  12. <param-value>0</param-value>
  13. </init-param>
  14. <init-param>
  15. <param-name>listings</param-name>
  16. <param-value>false</param-value>
  17. </init-param>
  18. <load-on-startup>1</load-on-startup>
  19. </servlet>
  20. <servlet>
  21. <servlet-name>jsp</servlet-name>
  22. <servlet-class>org.apache.jasper.servlet.jspservlet</servlet-class>
  23. <init-param>
  24. <param-name>fork</param-name>
  25. <param-value>false</param-value>
  26. </init-param>
  27. <init-param>
  28. <param-name>xpoweredby</param-name>
  29. <param-value>false</param-value>
  30. </init-param>
  31. <load-on-startup>3</load-on-startup>
  32. </servlet>
  33. <servlet-mapping>
  34. <servlet-name>default</servlet-name>
  35. <url-pattern>/</url-pattern>
  36. </servlet-mapping>
  37. <servlet-mapping>
  38. <servlet-name>jsp</servlet-name>
  39. <url-pattern>*.jsp</url-pattern>
  40. <url-pattern>*.jspx</url-pattern>
  41. </servlet-mapping>
  42. <session-config>
  43. <session-timeout>30</session-timeout>
  44. </session-config>
  45. <!--This omits the definition of a MIME type of about 4,000 lines, giving only two definitions of MIME types- -
  46. <mime-mapping>
  47. <extension>bmp</extension>
  48. <mime-type>image/bmp</mime-type>
  49. </mime-mapping>
  50. <mime-mapping>
  51. <extension>htm</extension>
  52. <mime-type>text/html</mime-type>
  53. </mime-mapping>
  54. <welcome-file-list>
  55. <welcome-file>index.html</welcome-file>
  56. <welcome-file>index.htm</welcome-file>
  57. <welcome-file>index.jsp</welcome-file>
  58. </welcome-file-list>
  59. </Web-app>


And after we have created a servlet, we need to configure the following basic content:

[HTML]View PlainCopy
  1. <servlet>
  2. <servlet-name>servlet name (self-starting, do not repeat)</servlet-name>
  3. <servlet-class>servlet class Path (xx.xx.xx.xxservlet)</servlet-class>
  4. </servlet>
  5. <servlet-mapping>
  6. <servlet-name>servlet name (same as above)</servlet-name>
  7. <url-pattern>/url name (own, do not repeat, note/, can not be lost)</url-pattern>
  8. </servlet-mapping>
The result is that a servlet class and URL path are bound together, meaning that our access to the/url name is actually accessing a servlet class;

In fact, the configuration of some development tools will be automatically configured, but we still need to understand, sometimes we need to match, or when you want to change.

Copyright notice: Here is Wolfarya's blog, are their own learning process, only for learning and reference, welcome to put forward comments and reprint qaq~

TOMCAT Web. XML Finishing Instructions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.