web.xml 中報錯

來源:互聯網
上載者:User

在web.xml加入taglib

<taglib>

<taglib-uri>/WEB-INF/tiles.tld</taglib- uri>

<taglib-location>/WEB-INF/tiles.tld</taglib- location>

</taglib>

 始終會報錯 這是使用版本的問題 如果是2.3版本是可以直接在<web-app>裡面書寫

 對於2.4(貌似是2.4及以後版本都是這樣)的web-app,taglib標籤的置放位置已經發生改變,要放在<jsp-config>標籤下

<jsp-config>

<taglib>

<taglib-uri>/WEB-INF/tiles.tld</taglib-uri>

<taglib-location>/WEB-INF/tiles.tld</taglib-location>

</taglib>

 </jsp-config>即可。下面給出一個完整2.5版本書寫方法:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
  <jsp-config>
       <taglib>
           <taglib-uri>/WEB-INF/tiles.tld</taglib-uri>
           <taglib-location>/WEB-INF/tiles.tld</taglib-location>
       </taglib>
  </jsp-config>  
</web-app>

其中,<taglib-location>/WEB-INF/tiles.tld</taglib-location>  就表明在你的項目WEB-INF下會有一個tld尾碼的名為titles的檔案。

         <taglib-uri>/WEB-INF/tiles.tld</taglib-uri>這裡應填的內容是取的tiles.tld檔案裡的這段話<uri>/WEB-INF/tiles.tld</uri>

  那麼這個tiles.tld檔案是哪裡來的呢    貌似可以自己編寫  (當然我是不會的- -。)

  我這想用的是struts2裡內建的標籤 所以就完全複製struts2-core-2.1.8.1.jar/META-INF/sturts-tags.tld裡面的內容到tiles.tld檔案裡。

  然後我們在JSP裡寫入<%@taglib  uri="/WEB-INF/tiles.tld"%> 這段話就可以用struts2內建的標籤功能了。

  {注意這個prefix="s" 中的s也是取的tiles.tld檔案裡的這段話<short-name>s</short-name>(應該是這樣,我個人的猜測)}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.