修改Servlet模版
来源:互联网 发布:淘宝运营教程百度网盘 编辑:程序博客网 时间:2024/06/09 18:15
在我们使用Myeclipse自动生成Servlet时,servlet模版会自动产生一个Servlet,但是里面显得比较乱,可以在MyEclipse中修改Servlet模版。
以Myeclipse10为例:
在\Common\plugins下的com.genuitec.eclipse.wizards_9.0.0.me201108091322.jar文件,可以用压缩软件直接打开。找到com.genuitec.eclipse.wizards_9.0.0.me201108091322.jar\templates下的Servlet.java
可以根据自己的需求更改:
比如我的更改如下(主要是对doGet()doPost()的修改):
#---------------------------------------------## <aw:description>Template for Servlet</aw:description># <aw:version>1.1</aw:version># <aw:date>04/05/2003</aw:date># <aw:author>Ferret Renaud</aw:author>#---------------------------------------------#<aw:import>java.io.IOException</aw:import><aw:import>java.io.PrintWriter</aw:import><aw:import>javax.servlet.ServletException</aw:import><aw:import>javax.servlet.http.HttpServlet</aw:import><aw:import>javax.servlet.http.HttpServletRequest</aw:import><aw:import>javax.servlet.http.HttpServletResponse</aw:import><aw:parentClass>javax.servlet.http.HttpServlet</aw:parentClass><aw:constructor name="c1">/** * Constructor of the object. */public <aw:className/>() {super();}</aw:constructor> <aw:method name="doGet">/** * The doGet method of the servlet. */public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/html");}</aw:method><aw:method name="doPost">/** * The doPost method of the servlet. */public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/html");this.doGet(request,response);}</aw:method><aw:method name="doPut">/** * The doPut method of the servlet. * * This method is called when a HTTP put request is received. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */public void doPut(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {// Put your code here}</aw:method><aw:method name="doDelete">/** * The doDelete method of the servlet. <br> * * This method is called when a HTTP delete request is received. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */public void doDelete(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {// Put your code here}</aw:method><aw:method name="init">/** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */public void init() throws ServletException {// Put your code here}</aw:method><aw:method name="destroy">/** * Destruction of the servlet. <br> */public void destroy() {super.destroy(); // Just puts "destroy" string in log// Put your code here}</aw:method><aw:method name="getServletInfo">/** * Returns information about the servlet, such as * author, version, and copyright. * * @return String information about this servlet */public String getServletInfo() {return "This is my default servlet created by Eclipse";}</aw:method>
0 0
- 修改Servlet模版
- 修改servlet模版
- javaweb如何修改servlet模版?
- 如何在MyEclipse中修改Servlet模版
- MyEclipse中修改创建servlet的模版
- MyEclipse8.0修改创建Servlet模版代码
- 修改MyEclipse 10的Servlet模版
- 如何在MyEclipse10中修改Servlet模版
- (3)MyEclipse修改Servlet默认模版
- myeclipse修改默认servlet模版方法
- [Servlet]为MyEclipse8.0修改创建Servlet模版代码
- [Servlet]为MyEclipse8.0修改创建Servlet模版代码
- 修改MyEclipse 10的Servlet、JSP模版代码
- 菜鸟学Andoid(二十一):Servlet的继承结构和修改Servlet模版
- servlet模版的更改
- Servletconfig和ServletContext(附mac+eclipse添加Servlet模版)(2017.9.28第一次修改版)
- 统一修改项目模版
- Lightinthebox模版快速修改
- 逻辑组合与代码整理及优化(三)
- 运行TLD时的initcamera问题
- Java线程池使用说明
- 此方法地方
- 面试
- 修改Servlet模版
- Eclipse常用快捷键
- ORA-19804: cannot reclaim 48156160 bytes disk space from 4039114752 limit
- 配置php环境
- Calendar类
- C语言中嵌入正则表达式
- java学习笔记四——表达式
- 轮廓提取
- SAP query传输以后需要重新生成程序