When use Maven to create Liferay portlet project, in the view.jsp. You might want to use jstl/core. When we define that, it'll give us a big error: according to tld or attribute directive in tag file attribute items does not accept any expressions
Don't worry, we have several things to check.
1. Do you add jstl.jar in your project. Download jstl-1.2.jar and add to your maven project.
2. In your pom.xml, add jstl dependency, otherwise, we need to copy jstl.jar to tomcat/lib/ext folder.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
3. In your jsp, make sure you use <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>, not <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>.
4. check DTD version you use in your web.xml
<web-app version="2.4" 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">
5. use that in your jsp
<c:forEach var="book" items="${books}">
<portlet:renderURL var="editBookURL">
<portlet:param name="myaction" value="editBookForm" />
<portlet:param name="bookId" value="${book.id}" />
</portlet:renderURL>
<portlet:resourceURL var="deleteBookURL">
<portlet:param name="myaction" value="deleteBook" />
<portlet:param name="bookId" value="${book.id}" />
</portlet:resourceURL>
<tr id="myrow_${book.id}">
<td valign="top">${book.id}</td>
<td valign="top">${book.title}</td>
<td valign="top">${book.author}</td>
<td valign="top">${book.isbn}</td>
<td valign="top">${book.summary}</td>
<td align="center" valign="top" width="100px"><a
href="<%=editBookURL%>">EDIT</a> /
<a id="removelink"
href="javascript:void(0)"
onclick="<portlet:namespace/>removeBook('<portlet:resourceURL></portlet:resourceURL>','${book.id}');">Remove</a></td>
</tr>
</c:forEach>
That's all! Well Done!
本文将指导您如何解决在使用Maven创建的Liferay Portlet项目中,jsp文件中引入JSTL时遇到的错误。通过检查jar包添加、依赖配置、jsp文件语法等步骤,确保项目正常运行。
448

被折叠的 条评论
为什么被折叠?



