简体   繁体   English

此令牌后应有标识符

[英]Identifier expected after this token

I got a error : Identifier expected after this token 我收到一个错误:此令牌后应有标识符

Syntax error on token "tag", Identifier expected after this token

And here is my code: 这是我的代码:

<%@ page import="photoshare.Picture" %>
<%@ page import="photoshare.PictureDao" %>
<%@ page import="photoshare.HREF_AND_IMGSRC" %>
<%@ page import="photoshare.ToolsDao" %>
<%@ page import="org.apache.commons.fileupload.FileUploadException" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Get POP Tags</title></head>
<body>
<h1>With Photos with popular Tags:</h1>

<%
String tagName = request.getParameter("tag");
List<String> popTags = new ArrayList<String>();
ToolsDao toolsDao = new ToolsDao();

popTags = toolsDao.getPopularTags();

for (tag:popTags) {%>
    <a href="popTags.jsp?tag=<%= tagName %>">tagName <a>

<%}


List<HREF_AND_IMGSRC> tagPhotos = toolsDao.getHrefAndImgSrcFromTag(tagName);
for (HREF_AND_IMGSRC photo:tagPhotos) {
    int pictureId = photo.getPictureID();
    int selectedAlbumID = photo.getAlbumID();
    String selectedAlbum_id = Integer.toString(selectedAlbumID);
%>
    <td><a href="picture.jsp?id=<%= pictureId %>&album_id=<%= selectedAlbum_id%>">
    <img src="/photoshare/img?t=1&picture_id=<%= pictureId %>"/></a></td>

<%
}
%>

Click here to <a href="index.jsp">Main Page</a><br>

</body>


</html>

I am finding some reasons for this but nothing similar, can anybody help me to figure out what is the problem for this specified error? 我发现了某些原因,但没有相似之处,有人可以帮助我找出此指定错误的问题吗?

I found the problem which is : 我发现的问题是:

for (tag:popTags) {%>
    <a href="popTags.jsp?tag=<%= tagName %>">tagName <a>
<%}

I have to declare the type of the tag in popTags list such as: 我必须在popTags列表中声明标签的类型,例如:

for (String tag:popTags) {%>
    <a href="popTags.jsp?tag=<%= tagName %>">tagName <a>

<%}

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

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