在Eclipse里面編寫的html和jsp模板並不符合我們現在使用的html5的規范,對此可以更改默認設置
自定義JSP模板
首先可以創建一個web 動態工程,右擊WebContent,選擇新建一個JSP File。注意:JSP和HTML一樣是要創建在服務器下的,即WebContent下。
具體步驟:
- 右擊WebContent,選擇新建一個JSP File,輸入要創建的文件名,不要立即finish,點擊Next
- 在彈出的頁面我們選擇最后一行的超鏈接"JSP Template",此處會跳轉到"Preferences(Filtered)"
- 我們可以在左側看到Preferences(Filtered) =》Web =》 JSP Files =》Editor =》Templates ,單擊"JSP Templates";
點擊右側的“New…”我們進行如下填寫:在Name里面填寫: New JSPFile (html 5),在Context選擇:New JSP,在Description中寫 JSP with html markup ,在Pattern做如下填寫:
1 <%@ page language="java" contentType="text/html; charset=${encoding}" 2 pageEncoding="${encoding}"%> 3 <!DOCTYPE html> 4 <html> 5 <head> 6 <meta charset="${encoding}"> 7 <title>Insert title here</title> 8 </head> 9 <body> 10 ${cursor} 11 </body> 12 </html>
5.然后ok,應用保存即可。
6.再一次創建的時候就可以選用剛剛新建的模板,直接finish就可以使用。
自定義HTML模板
與上述步驟相同,替換的html代碼如下面:
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="${encoding}"> 5 <title>Insert title here</title> 6 </head> 7 <body> 8 ${cursor} 9 </body> 10 </html>