according to tld or attribute directive in tag file attribute items does not accept any expressions

本文将指导您如何解决在使用Maven创建的Liferay Portlet项目中,jsp文件中引入JSTL时遇到的错误。通过检查jar包添加、依赖配置、jsp文件语法等步骤,确保项目正常运行。

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!

评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值