1、打开Intellij idea的settings,输入live templates
2、点击右侧“+”号添加模板(第一个是直接添加一个模板,第二个是添加一个模板组)
3、在模板中的①Abbreviation中输入到时候需要检索的单词,②Description中输入该模板描述,在③Template text中输入模板内容
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);
}
}