如何修改myeclipse 新建JSP檔案時的預設模板
第一種方法:
MyEclipse 6.0\myeclipse\eclipse\plugins\com.genuitec.eclipse.wizards_6.0.1.zmyeclipse601200710\templates\jsp
修改Jsp.vtl這個檔案就可以了
在X:\Program Files\MyEclipse6.0\myeclipse\eclipse\plugins\com.genuitec.eclipse.wizards_6.0.1.zmyeclipse601200710\templates\jsp 目錄下找到Jsp.vtl,複製一份,重新命名為jsp2.vtl,然後把裡面的內容修改為自己想要的格式,儲存。
然後在 X:\Program Files\MyEclipse6.0\myeclipse\eclipse\plugins\com.genuitec.eclipse.wizards_6.0.1.zmyeclipse601200710 目錄下找到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頁面就按你的模板生成了!
注意:
1.X:\Program Files\MyEclipse 6.0\ 是安裝myeclipse的路徑。
2.com.genuitec.eclipse.wizards_6.0.1.zmyeclipse601200710中的 wizards_6.0.1.zmyeclipse601200710根據版本的不同可能會不同,如可能為 com.genuitec.eclipse.wizards_6.0.0.zmyeclipse60020070820等。
一般情況我們只需修改模版資訊即可,例如修改JSP頁面檔案頭資訊
*#<%@ page language="java" import="java.util.*" pageEncoding="$encoding"%>
改為
*#<%@ page contentType="text/html; charset=$encoding"%>
第二種方法:
MyEclipse中構造新的jsp模板
首先隨便開啟一個jsp頁,在網頁中單擊右鍵選擇:preferences
開啟後如圖所示,找到jsp template選項.
選擇new,在彈出的提示框,輸入如圖所示內容,當然輸入你想要的就可以了.我這裡是 struts2.
點選ok就可以了. 下一步注意在建立的時候,一定要選擇Basic Jsp,如圖所示:
在接下來的頁面裡隨便輸入jsp的名字,然後next:
選擇你想要的模板(其中出現了剛才新新增的模板),點選Finish就ok了. 對於xml...etc其實都是一樣的,比如xml,只需要開啟一個xml檔案,在上面右鍵找到相應屬性,按上述類似步驟配置即可. 這樣做可以簡化我們的開發,提高效率.