问题
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):
- 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. Taglib Map in web.xml
, the web.xml can include an explicit map of URI's and TLD's respource paths.TLDs in JAR files in WEB-INF/lib
andTLDs under WEB-INF
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