Home  >  Article  >  Java  >  Eclipse adds servlet template process code

Eclipse adds servlet template process code

Guanhui
Guanhuiforward
2020-07-27 18:26:562475browse

Eclipse adds servlet template process code

Write a servlet template first

package com.exam.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * datatime: 2020年7月15日 下午9:04:18
 * Servlet implementation class dddd
 */
public class dddd extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("text/html;charset=utf-8");
		request.setCharacterEncoding("utf-8");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}
}

2. Add it to the eclipse template




Click ok again

Apply and close

Enter servlet in the opened class and press alt /

The current template will be output

Recommended tutorial: "Java Tutorial"

The above is the detailed content of Eclipse adds servlet template process code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete