Servlet template code in eclipse (actually the code prompt template), eclipseservlet

Source: Internet
Author: User

Servlet template code in eclipse (actually the code prompt template), eclipseservlet

It refers to the template code. It should be said that the template code is prompted, and a template will appear if it is not a new one.

Step 1: first create a Servlet File and write the template you want

My template is as follows:

Select and copy all, and paste them to the prompt template of the Servlet.

Package online. msym; // This line of code will be deleted, and the next line of code will open // package $ {enclosing_package}; // This line of code is used to automatically identify the package and export the package import java. io. IOException; import javax. servlet. servletException; import javax. servlet. http. httpServlet; import javax. servlet. http. httpServletRequest; import javax. servlet. http. httpServletResponse; public class ServletDemo extends HttpServlet {protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// For get request garbled solution, first using iso8859-1 encoding, then use UTF-8 to decode doPost (request, response);} protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// FOR post requests, set the request encoding, prevent garbled requests. setCharacterEncoding ("UTF-8"); // sets the response body encoding and the browser decoding encoding response. setContentType ("text/html; charset = UTF-8 ");}}
Step 2: Set template operation steps Window --> Java --> Editor --> Templates --> New

 

Click New and paste the Servlet code that has just been assigned the Template Name, description, and template content. Note that the first line is removed and the code comment of the second line is opened.

 

 

Next we will create a Servlet. After the Servlet is created, the template we set will not appear. This is why I say it is a code prompt template. below is the modified DemoServlet.

Select All, enter servlet, press Alt +/code to prompt the key combination, and then modify the class name.

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.