您的位置:首页 > 其它

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

2012-11-03 05:14 369 查看
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!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐