在MyEclipse for mac 中增加、修改JSP模板

修改模板: 
找到com.genuitec.eclipse.wizards_9.0.0.me201108091322.jar,至少格式是前綴是一樣,每個版本不一樣,我的是myeclipse10. 
然後用war軟件打開。 
新建一個Struts2_jsp.vtl 

Struts2_jsp.vtl 
------------------------------------- 
Jsp代碼  收藏代碼
  1. <%@ page language="java" import="java.util.*"  pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>  
  2. <%@ taglib prefix="s" uri="/struts-tags"%>  
  3. <%  
  4.     String titleString = "My Struts2 JSP Template";  
  5.     String footerString= "My Struts2 JSP Template";  
  6.     String path = request.getContextPath();  
  7.     String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
  8. %>  
  9. <html>  
  10.     <head>  
  11.         <title><%=titleString%></title>  
  12.     </head>  
  13.     <body>  
  14.         <center><h1><%=titleString%></h1></center>  
  15.         <hr>  
  16.         <%=new Date()%><br>  
  17.         Actionerror:<s:actionerror/><br>  
  18.         Actionmessage:<s:actionmessage/><br>  
  19.         <hr>  
  20.         <div style="height:100%;border:1px solid #6699FF">  
  21.             <s:form action="myAction" method="post">  
  22.                 <s:textfield name="user" label="UserName" value="default value" size="50"></s:textfield>  
  23.                 <s:submit value="Submit"></s:submit>  
  24.             </s:form>  
  25.         </div>  
  26.         <hr>  
  27.         <center><%=footerString%></center>  
  28.     </body>  
  29. </html>  




然後把這個文件放到jar裏面的com.genuitec.eclipse.wizards_9.0.0.me201108091322.jar\templates\jsp 
然後回到com.genuitec.eclipse.wizards_9.0.0.me201108091322.jar最外面的,看見templates.xml 
解壓出來,然後在<!-- JSP templates -->的後面增加如下代碼: 
Xml代碼  收藏代碼
  1. <template  
  2.         context="com.genuitec.eclipse.wizards.jsp"  
  3.         script="templates/jsp/Struts2_jsp.vtl"  
  4.         name="Standard JSP using Struts 2.X with a form"/>  


保存之後,在放到war打開的jar一樣的地方那個,覆蓋裏面的文件。 
然後啓動myeclipse,點new/jsp   然後就能選擇剛纔的模板了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章