Eclipse添加servlet模板过程代码详解
程序员文章站
2022-04-21 12:43:24
1.先写好一个servlet模板package com.exam.servlet;import java.io.ioexception;import javax.servlet.servletexce...
1.先写好一个servlet模板
package com.exam.servlet; import java.io.ioexception; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; /** * datatime: 2020年7月15日 下午9:04:18 * servlet implementation class dddd */ public class dddd extends httpservlet { private static final long serialversionuid = 1l; /** * @see httpservlet#doget(httpservletrequest request, httpservletresponse response) */ protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { // todo auto-generated method stub response.setcontenttype("text/html;charset=utf-8"); request.setcharacterencoding("utf-8"); } /** * @see httpservlet#dopost(httpservletrequest request, httpservletresponse response) */ protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { // todo auto-generated method stub doget(request, response); } }
2.添加到eclipse模板中
再点击ok
应用并关闭
再打开的类中输入servlet按alt+/
就会输出当前的模板
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
下一篇: Js图片点击切换轮播实现代码