在jsp里面写java代码,前台的jsp是foreach循环显示的,代码如下:不知错在哪?

在后台中将数据全部存入了名为:porfiles 的集合中。
在前台的jsp中用了 :foreach循环遍历出来。
在遍历的过程中,需要判断一个字段是否为 1;
jsp代码:

<c:forEach var="porfiles" items="${sessionScope.porfiles}">
                    <tr class="text-c">
                        <td style="width:20px">${porfiles.iwn }</td>
                        <td style="width:20px">${porfiles.jsex }</td>
                        <td style="width:20px">${porfiles.jaddress }</td>
                        
                    <!-- 在这里判断一下  moments字段是否为1. 若为1: 显示下面那个<td>; 若为0 :显示上面那个<td>-->    
                         <% if(%> ${porfiles.moments }  <% =="0"){ %>
                            <td style="width:20px"></td> 
                            
                            <% }else { %> 
                         <td style="width:20px"><a href="javascript:;"
                            onclick="bigmoments('${porfiles.jeq},${porfiles.jgr },${porfiles.iwn },${porfiles.jyf },siteuser')"><img
                                src="img/penyou.jpg" style="width: 36;height: 36"></a> <input
                            type="hidden" id="eeq" value="${porfiles.jeq }" /></td> 
                            
                           <%}%> 
                    </tr>
                    <tr class="text-c">
                        <td colspan="9" style="text-align: left"><span class="BW"><strong>微信特征码:</strong></span>
                            ${porfiles.jyf }</td>
                    </tr>
                </c:forEach>

                

这个判断 我能想到的解决办法就是在前台显示的时候做判断。如果有更好的办法也欢迎大家的建议。
但是报错了:不知道什么原因?错误如下:

严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 383 in the jsp file: /siteuser.jsp
Syntax error on token(s), misplaced construct(s)
380: </thead>
381:
382: <tbody>
383: <c:forEach var="porfiles" items="${sessionScope.porfiles}">
384: <tr class="text-c">
385:
386: <td rowspan="3"><a href="javascript:;"

An error occurred at line: 399 in the jsp file: /siteuser.jsp
Syntax error, insert ") Statement" to complete IfStatement
396: <td style="width:20px">${porfiles.iwn }</td>
397: <td style="width:20px">${porfiles.jsex }</td>
398: <td style="width:20px">${porfiles.jaddress }</td>
399: <% if(%> ${porfiles.moments } <% =="0"){ %>
400: <td style="width:20px"></td>
401: <% }else { %>
402: <td style="width:20px"><a href="javascript:;"

阅读 5k
1 个回答

383行,语法错误,提示已经很清晰了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题