IDEA自定义Servlet模版
程序员文章站
2023-12-23 22:27:57
...
IDEA自定义Servlet模版步骤:
(每天一个偷懒小技巧!)
File——>Settings——>搜索栏搜索code tem(注意有空格)——>选择Other——>下拉列表选择Web——>选择Java
code templates——>选择Servlet Annotated Class.java
模版代码如下:(可以直接复制粘贴过去)
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
@javax.servlet.annotation.WebServlet("/${Entity_Name}")
public class ${Class_Name} extends javax.servlet.http.HttpServlet {
protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
}
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
this.doPost(request,response);
}
}
粘贴完之后,记得先点击Apply——>再点击OK