JavaWeb——jsp-config
阿新 • • 發佈:2019-01-14
<jsp-config> 包括 <taglib> 和 <jsp-property-group> 兩個子元素。其中<taglib> 元素在JSP 1.2 時就已經存在;而<jsp-property-group> 是JSP 2.0 新增的元素。<jsp-property-group> 元素主要有八個子元素,它們分別為:
1.<description>:設定的說明
2.<display-name>:設定名稱
3.<url-pattern>:設定值所影響的範圍,如: /CH2 或 /*.jsp
4.<el-ignored>:若為 true,表示不支援 EL 語法
5.<scripting-invalid>:若為 true,表示不支援 <% scripting %>語法
6.<page-encoding>:設定 JSP 網頁的編碼
7.<include-prelude>:設定 JSP 網頁的擡頭,副檔名為 .jspf
8.<include-coda>:設定 JSP 網頁的結尾,副檔名為 .jspf 貼一個簡單配置: view plaincopy to clipboardprint?
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/jsp/segments/taglibs.jspf</include-prelude>
<include-coda>/jsp/segments/coda.jspf</include-coda>
</jsp-property-group>
<jsp-property-group>
<url-pattern>*.do</url-pattern>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/jsp/segments/taglibs.jspf</include-prelude>
<include-prelude>/jsp/segments/coda.jspf</include-prelude>
</jsp-property-group>
</jsp-config>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/jsp/segments/taglibs.jspf</include-prelude>
<include-coda>/jsp/segments/coda.jspf</include-coda>
</jsp-property-group>
<jsp-property-group>
<url-pattern>*.do</url-pattern>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/jsp/segments/taglibs.jspf</include-prelude>
<include-prelude>/jsp/segments/coda.jspf</include-prelude>
</jsp-property-group>
</jsp-config> 以上配置指明在所有*.jsp,*.do的路徑中投不能是使用scriptlet(jsp 指令碼),因為這會是java程式碼和html程式碼混雜在一起,稀釋了程式碼的清晰度,增加專案維護難度。include-prelude設定每個檔案的擡頭為/jsp/segments/taglibs.jspf,include-prelude設定了每個檔案的結尾/jsp/segments/coda.jspf,記住,引入的檔案必須是以.jspf為字尾的jsp外掛框架檔案。 通過引入擡頭和結尾可以做一些標籤申明和版權申明等類似工作。覺得很值得提倡!
1.<description>:設定的說明
2.<display-name>:設定名稱
3.<url-pattern>:設定值所影響的範圍,如: /CH2 或 /*.jsp
4.<el-ignored>:若為 true,表示不支援 EL 語法
5.<scripting-invalid>:若為 true,表示不支援 <% scripting %>語法
6.<page-encoding>:設定 JSP 網頁的編碼
7.<include-prelude>:設定 JSP 網頁的擡頭,副檔名為 .jspf
8.<include-coda>:設定 JSP 網頁的結尾,副檔名為 .jspf 貼一個簡單配置: view plaincopy to clipboardprint?
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/jsp/segments/taglibs.jspf</include-prelude>
<include-coda>/jsp/segments/coda.jspf</include-coda>
</jsp-property-group>
<jsp-property-group>
<url-pattern>*.do</url-pattern>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/jsp/segments/taglibs.jspf</include-prelude>
<include-prelude>/jsp/segments/coda.jspf</include-prelude>
</jsp-property-group>
</jsp-config>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/jsp/segments/taglibs.jspf</include-prelude>
<include-coda>/jsp/segments/coda.jspf</include-coda>
</jsp-property-group>
<jsp-property-group>
<url-pattern>*.do</url-pattern>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/jsp/segments/taglibs.jspf</include-prelude>
<include-prelude>/jsp/segments/coda.jspf</include-prelude>
</jsp-property-group>
</jsp-config> 以上配置指明在所有*.jsp,*.do的路徑中投不能是使用scriptlet(jsp 指令碼),因為這會是java程式碼和html程式碼混雜在一起,稀釋了程式碼的清晰度,增加專案維護難度。include-prelude設定每個檔案的擡頭為/jsp/segments/taglibs.jspf,include-prelude設定了每個檔案的結尾/jsp/segments/coda.jspf,記住,引入的檔案必須是以.jspf為字尾的jsp外掛框架檔案。 通過引入擡頭和結尾可以做一些標籤申明和版權申明等類似工作。覺得很值得提倡!