0
我想在我的liferay 6.0 portlet應用程序中使用JSP 2.0標記文件。爲什麼JSP 2.0自定義標記文件不適用於Portlet?
下面是我遵循的步驟:
我的JSP很簡單:
home.jsp
。<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <table> <tr> <td> <tags:tagDemo/> </td> <td><c:out value="Cout Hello"/></td> </tr> </table>
我的標籤文件是超簡單:
/WEB-INF/tags/tagDemo.tag
hello
/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web- app_2_4.xsd" version="2.4"> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/classes/log4j.properties</param-value> </context-param> <servlet> <servlet-name>view-servlet</servlet-name> <servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>view-servlet</servlet-name> <url-pattern>/WEB-INF/servlet/view</url-pattern> </servlet-mapping> </web-app>
這引發以下錯誤:
00:14:42,642 ERROR [render_portlet_jsp:154] org.apache.jasper.JasperException: /WEB-INF/jsp/home.jsp (line: 55, column: 6) No tag "tagDemo" defined in tag library imported with prefix "tags"
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:199)
at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1215)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1450)
at org.apache.jasper.compiler.Parser.parse(Parser.java:138)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
有人能告訴我問題在哪裏嗎?
不,那不行。我們不需要也不應該在指令中考慮實際的標籤名稱。 – 2012-08-16 20:10:33
JSP 2.0自定義標籤在liferay 6.0 portlet中無效。但不知何故,他們在liferay 5.x portlet中工作。 – 2012-08-16 20:11:24
奇怪的是它在5.x中工作,而不是在6.0中。希望你有'jstl'的正確的jar文件。其次,爲什麼我們不應該提及實際的標籤名稱?任何參考?我還沒有嘗試,但任何理由或參考將有所幫助。 – 2012-08-17 06:18:35