首頁  >  文章  >  Java  >  Eclipse 新增 servlet 模板過程程式碼

Eclipse 新增 servlet 模板過程程式碼

Guanhui
Guanhui轉載
2020-07-27 18:26:562481瀏覽

Eclipse 新增 servlet 模板過程程式碼

先寫好一個servlet模板

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.加入到eclipse模板中




再點選ok

應用並關閉

再開啟的類別中輸入servlet按alt /

就會輸出目前的範本

推薦教學:《Java教學

以上是Eclipse 新增 servlet 模板過程程式碼的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:jb51.net。如有侵權,請聯絡admin@php.cn刪除