idea自定义servlet模板

 

 

 1 #if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
 2 #parse("File Header.java")
 3 /**
 4  * @Description TODO
 5  * @ClassName ${Class_Name}
 6  * @Author ${USER}
 7  * @Date ${DATE} ${TIME}
 8  */
 9 @javax.servlet.annotation.WebServlet(value="/${Entity_Name}")
10 public class ${Class_Name} extends javax.servlet.http.HttpServlet {
11     @Override
12     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
13         /* 处理响应乱码问题:字节流需getBytes("UTF-8") */
14         response.setContentType("text/html;charset=UTF-8");
15         /* 处理post请求乱码问题 */
16         request.setCharacterEncoding("UTF-8");
17     }
18 
19     @Override
20     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
21         doGet(request, response);
22     }
23 }

 

posted @ 2019-11-11 11:41  养一只Tom猫  阅读(1650)  评论(0编辑  收藏  举报