简体   繁体   English

JSP定制Taglib

[英]JSP Custom Taglib

I'm running in Liferay 7 but I am trying to create a custom tag but keep getting this error when I try to run it. 我在Liferay 7中运行,但是我试图创建一个自定义标签,但是在尝试运行它时始终出现此错误。

[fileinstall-/Development/liferay-ce-portal-7.0-ga3/osgi/war][org_apache_felix_fileinstall:103] Error while starting bundle: webbundle:file:/Development/liferay-ce-portal-7.0-ga3/osgi/war/digital-lexicon-portlet-7.0.0.1.war?Bundle-SymbolicName=digital-lexicon-portlet&Web-ContextPath=/digital-lexicon-portlet 
org.osgi.framework.BundleException: Could not resolve module: digital-lexicon-portlet [587]_  Unresolved requirement: Import-Package: com.swabunga.spell.engine; resolution:="optional"_  Unresolved requirement: Import-Package: com.swabunga.spell.event; resolution:="optional"_  Unresolved requirement: Import-Package: net.fortuna.ical4j.model; resolution:="optional"_  Unresolved requirement: Import-Package: net.fortuna.ical4j.model.property; resolution:="optional"_  Unresolved requirement: Import-Package: org.apache.axis.tools.ant.wsdl; resolution:="optional"_  Unresolved requirement: Import-Package: org.apache.bsf; resolution:="optional"_  Unresolved requirement: Import-Package: org.apache.poi.hssf.usermodel; resolution:="optional"_  Unresolved requirement: Import-Package: org.apache.poi.ss.usermodel; resolution:="optional"_  Unresolved requirement: Import-Package: org.apache.portals.bridges.common; resolution:="optional"_  Unresolved requirement: Import-Package: org.apache.portals.bridges.struts; resolution:="optional"_  Unresolved requirement: Require-Capability: osgi.extender; filter:="(&(osgi.extender=jsp.taglib)(uri=/WEB-INF/tld/tile.tld))"_ [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:429)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:402)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1252)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1224)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:313)

I've followed tutorials and my structure looks like this: 我遵循了教程,其结构如下所示:

docroot/WEB-INF/src
  com.lexicon
    - TileTag.java
  com.liferay.docs.lexicon.portlet
    - LexiconPortlet.java

My TileTag.java looks like this: 我的TileTag.java看起来像这样:

package com.liferay.docs.lexicon.portlet;

import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;
import java.io.*;

public class TileTag extends SimpleTagSupport {

  public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();
    out.println("Hello Custom Tag!");
  }
}

My docroot/WEB-INF/tld/tile.tld looks like this: 我的docroot/WEB-INF/tld/tile.tld看起来像这样:

<?xml version="1.0"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">

<taglib>
  <tlib-version>1.0</tlib-version>
  <jsp-version>2.0</jsp-version>
  <short-name>UI Tile</short-name>
  <tag>
    <name>tile</name>
    <tag-class>com.liferay.docs.lexicon.portlet.TileTag</tag-class>
    <body-content>empty</body-content>
  </tag>

In my view.jsp I have: 在我的view.jsp我有:

<%@ taglib uri="/WEB-INF/tld/tile.tld" prefix="lex" %>
<lex:tile />

I've run into almost the exact same situation. 我遇到了几乎完全相同的情况。 I'm porting a JBoss Portal portlet project that produces a war file, and works perfectly, to a Liferay Portal / Wildfly environment. 我正在将一个JBoss Portal portlet项目移植到Liferay Portal / Wildfly环境中,该项目将生成一个war文件,并且可以完美运行。 When I remove the <%@taglib descriptor from my JSP file, the BundleException goes away (which shows that that is what is causing the problem), but I lose the taglib functionality in the JSP, which is the whole point of including it in the first place. 当我从JSP文件中删除<%@ taglib描述符时,BundleException消失了(这表明是问题所在),但是我失去了JSP中的taglib功能,这就是在其中包含它的全部目的。第一名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM