Liferay Taglib import not working in JSP

倖福魔咒の 提交于 2019-12-10 10:05:43

问题


I'm having trouble importing the liferay taglibs in one of my JSP pages, no idea what I'm doing wrong. I did the exact same thing in previous projects, but now for some reason it's not working.

My code to import:

<%@ taglib uri="http://liferay.com/tld.ui" prefix="liferay-ui" %>

The syntax error I'm getting:

The absolute uri: http://liferay.com/tld.ui cannot be resolved in either web.xml or the jar files deployed with this application

I tried to google this problem quite extensively, but to no avail. The horrible documentation (or lack thereof) for liferay is also not a big help at all.

Thanks in advance for any help!


回答1:


The taglib URI gets resolved from the following places(in the order):

  1. If the container is Java EE platform compliant, the tag libraries that are part of the Java EE platform. This currently includes JSTL and JSF Tag Library libraries.
  2. Taglib Map in web.xml, the web.xml can include an explicit map of URI's and TLD's respource paths.
  3. TLDs in JAR files in WEB-INF/lib and TLDs under WEB-INF
  4. TLD's supported by Container

In you case, check the following cases: 1) If jar file realted to liferay exists in WEB-INF/lib containing a TLD in jar/META-INF which will be defined with http://liferay.com/tld.ui URI. 2) If there is not jar file and the liferay-ui.tld exists outside the jar file, add the URI mapping entrey in your web.xml like below:

<taglib>
    <taglib-uri>http://liferay.com/tld/ui</taglib-uri>
    <taglib-location>/WEB-INF/tld/liferay-ui.tld</taglib-location>
</taglib>



回答2:


it is not

<%@ taglib uri="http://liferay.com/tld.ui" prefix="liferay-ui" %>

it should be

<%@ taglib prefix="liferay-ui" uri="http://liferay.com/tld/ui" %>

notice that "tld.ui" must be "tld/ui".

liferay-ui.tld comes from util-taglib.jar that liferay adds to your WEB-INF/lib during hot deploy.

No entries to your web.xml are needed.




回答3:


You probably need to include taglib declaration in your web.xml.

    <taglib>
        <taglib-uri>http://liferay.com/tld/ui</taglib-uri>
        <taglib-location>/WEB-INF/tld/liferay-ui.tld</taglib-location>
    </taglib>


来源:https://stackoverflow.com/questions/8061648/liferay-taglib-import-not-working-in-jsp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!