1、打開Intellij idea的settings,輸入live templates
2筑公、點擊右側(cè)“+”號添加模板(第一個是直接添加一個模板,第二個是添加一個模板組)
3尊浪、在模板中的①Abbreviation中輸入到時候需要檢索的單詞匣屡,②Description中輸入該模板描述封救,在③Template text中輸入模板內(nèi)容
package $package_name$;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name ="$class_name$", urlPatterns ="/$class_name$")
public class$ class_name $extendsHttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)throwsServletException,IOException {
response.getWriter().write("Hello Kimen");
}
public void doPost(HttpServletRequest request,HttpServletResponse response)throwsServletException,IOException {
doGet(request,response);
}
}