MyEclipse 中修改和增加JSP和Struts2的模板

34 篇文章 0 订阅
28 篇文章 0 订阅

myeclipse版本是6.5,安装在d:/Program/MyEclipse 6.5

1 新增jsp模板
在D:/Program/MyEclipse 6.5/myeclipse/eclipse/plugins/com.genuitec.eclipse.wizards_6.5.0.zmyeclipse650200806/templates/jsp目录下找到Jsp.vtl,复制一份,重命名为jsp2.vtl,然后把里面的内容修改为自己想要的格式,保存。
然后在 D:/Program/MyEclipse 6.5/myeclipse/eclipse/plugins/com.genuitec.eclipse.wizards_6.5.0.zmyeclipse650200806 目录下找到templates.xml,用文本编辑器打开。在
    <template
        context="com.genuitec.eclipse.wizards.jsp"
        script="templates/jsp/Jsp.vtl"
        name="Default JSP template"/>
下面增加
    <template
        context="com.genuitec.eclipse.wizards.jsp"
        script="templates/jsp/jsp2.vtl"
        name="JSP2 template"/>
保存。重启eclipse。
新建jsp,在模板中就会出现JSP2 template,选中,按完成,新建的jsp页面就按你的模板生成了!

    2新增Struts2模板
  同理找到D:/Program/MyEclipse 6.5/myeclipse/eclipse/plugins/com.genuitec.eclipse.wizards_6.5.0.zmyeclipse650200806/templates/jsp新建一个Struts2.tvl文件
代码如下
#*---------------------------------------------#
# Template for a Struts2
# @version: 1
#---------------------------------------------#
*#<%@ page language="java" pageEncoding="$encoding"%>
< %@taglib uri="/struts-tags"  prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>   
    <title>'$title'</title>
   
 #parse( "templates/jsp/JSPMetaTags.vtl" )
  </head>
 
  <body>
  <s:debug/>
  </body>
</html>
在templates.xml中找到
<template
  context="com.genuitec.eclipse.wizards.jsp"
  script="templates/jsp/Struts-1_2-form.vtl"
  name="Standard JSP using Struts 1.2/1.3 with a form"/>
紧跟其后添加
 <template
  context="com.genuitec.eclipse.wizards.jsp"
  script="templates/jsp/Struts2.vtl"
  name="Standard JSP using Struts2"/>
至此模板新建结束。
注意:
1.D:/Program/MyEclipse 6.5/ 是安装myeclipse的路径。
2.com.genuitec.eclipse.wizards_6.5.0.zmyeclipse650200806中的wizards_6.5.0.zmyeclipse650200806根据版本的不同可能会不同,如可能为com.genuitec.eclipse.wizards_6.0.0.zmyeclipse60020070820等。

一般情况我们只需修改模版信息即可,例如修改JSP页面文件头信息

*#<%@ page language="java" import="java.util.*" pageEncoding="$encoding"%>

改为 *#<%@ page contentType="text/html; charset=$encoding"%>
 
使用方法:
1选择功能菜单
2 新建页面向导
3查看页面



适合自己的模板能帮助开发人员节省很多时间,经过以上模板优化这样做可以简化我们的开发,提高效率了.

转帖:http://hi.baidu.com/passedbylove/blog/item/743189b3353605b4d9335ae2.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值