myeclipse的servlet模板替换

用myeclipse的创建servlet时,生成的类看起来让人很郁闷,里面的doPost方法和doGet方法有注释,而且里面也已经写了一些内容了,怎样修改呢?

首先,在myeclipse的安装目录下搜索com.genuitec.eclipse.wizards,搜索到的结果如图所示:

com.genuitec.eclipse.wizards_11.0.0.me201303311935.jar(不同版本的myeclipse这个文件名的最后有可能不同)这个jar文件就是我们要找的文件,然后打开这个文件,找到这个jar文件的templates目录下的Servlet.java文件,这个就是创建servlet时,myeclipse所使用的模板文件,接下来就是对这个文件进行修改,建议修改前先对这个文件进行备份。将这个文件拷贝出来,然后用编辑器打开,大致看一下这个文件,文件开始以#开始的行应该是一些注释信息,<aw:import>表示的是要导入的包,<aw:parentClass>表示该servlet继承的父类,<aw:constructor表示的是构造器,<aw:method
表示的是方法的声明
,知道这些以后,OK!开始修改吧多找到<aw:method name="doGet">将doGet方法里面的内容替换成doPost(request, response); 并把上面的JavaDoc删掉,然后找到<aw:method name="doPost">把方法体的内容去掉,并去掉javaDoc,最后清理下导入包。我把我最后修改的结果贴出来,如果有需要可以自行修改一些东西,下面贴出来主要是为了方便大家查看:

文件名:Servlet.java

#---------------------------------------------#
# <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>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. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 *
	 * @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 doGet(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException {

		doPost(request, response);
	}

</aw:method>

<aw:method name="doPost">
	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 *
	 * @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 doPost(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException {

	}

</aw:method>

<aw:method name="doPut">
	/**
	 * The doPut method of the servlet. <br>
	 *
	 * 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>
时间: 2024-07-30 08:08:22

myeclipse的servlet模板替换的相关文章

修改myeclipse的servlet模板

今天修改myeclipse的servlet模板时,发生 Could not create the view: An unexpected exception was thrown.错误. 解决方案:1.换工作空间,但是此方法较为麻烦,需要进行系列重新配置2.将MyEclipse工作空间中\.metadata\.plugins\org.eclipse.core.runtime\.settings路径下 com.genuitec.eclipse.ast.deploy.core文件删除即可!!

MyEclipse自定义servlet模板

每次用MyEclipse默认的servlet的模板创建servlet的时候,里面会生成好多没有用的代码.因此,我们可以自定义servlet模板.步骤如下: 找到com.genuitec.eclipse.wizards_11.5.0.me201310291746.jar 文件,该文件在MyEclipse(本人安装的是MyEclipse Professional 2014)安装目录下的/plugins下 打开com.genuitec.eclipse.wizards_11.5.0.me20131029

MyEclipse中修改servlet模板

1.在MyEclipse目录下搜索com.genuitec.eclipse.wizards,得到搜索结果 com.genuitec.eclipse.wizards_8.4.100.me200912131330.jar(我的位置是:C:\Users\Administrator\AppData\Local\Genuitec\Common\plugins): 2.备份,复制粘贴一份,完全关闭MyEclipse: 3.使用winrar打开com.genuitec.eclipse.wizards_8.4.

修改 MyEclipse 中的 jsp 和 servlet 模板

找到  MyEclipse/Common/plugins/com.genuitec.eclipse.wizards_9.0.0.me201211011550.jar 这个文件(wizards后面的数字可能不同) servlet 模板为 .jar/templates/Servlet.java <aw:method name="doGet">      public void doGet(HttpServletRequest request, HttpServletRespon

JavaWeb学习之Servlet(二)----Servlet的生命周期、继承结构、修改Servlet模板

[声明] 欢迎转载,但请保留文章原始出处→_→ 文章来源:http://www.cnblogs.com/smyhvae/p/4140466.html 联系方式:[email protected] 一.http协议回顾: 在上一篇文章中:JavaWeb学习之Servlet(一)----MyEclipse及Tomcat的配置,我们通过在浏览器输入url,就能看到在MyEclipse中编写的Servlet资源,效果如下: 上图中,整个过程是这样的:浏览器中输入url后,会通过hosts文件/dns服务

30天轻松学习javaweb_修改tomcat的servlet模板

在MyEclipse目录下搜索com.genuitec.eclipse.wizards得到搜索结果 com.genuitec.eclipse.wizards_9.0.0.me201108091322.jar解压出文件夹,修改com.genuitec.eclipse.wizards_9.0.0.me201108091322\templates\Servlet.java 的模板文件使用jar命令将文件夹打包成jar包:1.在dos窗口中进入到解压后的com.genuitec.eclipse.wiza

修改 myeclipse8.5 servlet 模板

在myeclipse8.5的安装目录下找到 \Common\plugins下的com.genuitec.eclipse.wizards_8.5.0.zmyeclipse75020090612.jar 注意先关闭myeclipse. 1.找到Genuitec\Common\plugins下的com.genuitec.eclipse.wizards_8.5.0.zmyeclipse75020090612.jar ( "Common"和"MyEclipse 8.5"同在&

ThinkPHP模板替换

该替换操作仅针对内置的模版引擎 __ROOT__: 会替换成当前网站的地址(不含域名) __APP__: 会替换成当前应用的URL地址 (不含域名) __MODULE__:会替换成当前模块的URL地址 (不含域名) __CONTROLLER__(__或者__URL__ 兼容考虑): 会替换成当前控制器的URL地址(不含域名) __ACTION__:会替换成当前操作的URL地址 (不含域名) __SELF__: 会替换成当前的页面URL __PUBLIC__:会被替换成当前网站的公共目录 通常是

编写一个简单的js模板替换工具 rtt----replace templete tool

最近一段时间在修改自己的个人在线简历.  这个在线简历用到了css3来制作3D的旋转效果, 因此会有兼容性问题, 针对于不支持css3的3D透视的浏览器, 比如 IE,  360等等, 我使用的是另一套css文件兼容.  针对于移动端浏览器, 尽管基本都是webkit内核, 但经测试发现3D效果并不流畅, 因此移动端是识别userAgent切换到另一套非3D页面.  因为没用任何数据库, 那么问题就来了, 移动端和pc端两套页面是共用的一套数据, 我想到的方法有两个: 一是页面加载之后用ajax