Enable a piece of code as the project starts

Source: Internet
Author: User

Only three steps are required:

1. Create a servlet for your code and rewrite the init () method. The content is the code or method interface to be executed;

2. configure it in the project's web. xml file. (For example, if the servlet name is ftpfileServlet

<Servlet>

<Servlet-name> ftpfileServlet </servlet-name>

<Servlet-class> sdcncsi. ict. jmt. ftpfileload. ftpfileServlet </servlet-class>

<Load-on-startup> 2 </load-on-startup>

</Servlet>


<Servlet-mapping>

<Servlet-name> ftpfileServlet </servlet-name>

<Url-pattern>/servlet/ftpfileServlet </url-pattern>

</Servlet-mapping>

The url-pattern changes with the change during creation. The integer value of load-on-startup is the priority, which is described by google .)

3. Start.

This article from the "calf" blog, please be sure to keep this source http://xiaoniudu.blog.51cto.com/7952142/1300878

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.