Optimize Servlet configuration for web. xml slimming

Source: Internet
Author: User

In the past, each Servlet was added in web. xml. As the project progresses, the number of servlets is growing.

The web. xml file is full. There is a way to improve the situation of these uninteresting things.

Add the following Servlet configuration in web. xml:

 
 
  1. <servlet> 
  2. <servlet-name>InvokerServlet servlet-name> 
  3. <servlet-class> 
  4. org.apache.catalina.servlets.InvokerServlet  
  5. servlet-class> 
  6. <init-param> 
  7. <param-name>debug param-name> 
  8. <param-value>0 param-value> 
  9. init-param> 
  10. <load-on-startup>-1 load-on-startup> 
  11. servlet> 
  12. <servlet-mapping> 
  13. <servlet-name>InvokerServlet servlet-name> 
  14. <url-pattern>/servlet/* url-pattern> 
  15. servlet-mapping> 

OK. Now, this Servlet configuration can be retained in web. xml to meet all Servlet calls. For example, to call the Servlet UserManagerService, write it in the page form as follows:

 
 
  1. <form name="f" method="post" action="/servlet/com.mashiguang.
    servlet.UserManagerService"> 
  2. <input/> 
  3. <submit/> 
  4. form> 

Note that the form action "/Servlet/" is followed by the full name of this Servletclass. The Servlet configuration is web. xml slimming.

  1. Servlet Engine installation
  2. Configure the Servlet Development Environment
  3. JSP Servlet call in tag Library
  4. Small issues encountered when learning Java Servlet
  5. Servlet sharing links in sessions

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.