Eclipse配置Servlet模板
程序员文章站
2022-06-03 09:57:35
...
这里以Eclipse4.5.2版本为例:
1.打开Eclilpse,Window->Preferences
2.Java->Editor->Templates->New
配置如图:
Pattern内容如下:
package ${enclosing_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 ${primary_type_name} extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().write("hello haohao...");
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
勾选上“Use code formatter”->Apply->OK
3.重启Eclipse
4.使用Alt+/来快速匹配出模板,创建出简单清晰的Servlet
上一篇: Docker中数据管理