错误:否则,如果没有.但是我把它放在后面 [英] error : else without if . But i have placed it immediately after it
本文介绍了错误:否则,如果没有.但是我把它放在后面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我执行以下代码时:
<script type="text/javascript">
function UploadMessage() {
<%! String message = null;
boolean AttemptToUploadFile = false;
%>
<%
message = (String)request.getAttribute("SuccessMessage");
if(message != null) {
%>
alert("File Successfully Uploaded !");
<% } %>
<% else if((Boolean)request.getAttribute("UploadAttempt")) { %>
alert("Unable to upload file");
<%}%>
}
我收到以下错误:
media/work documents/UnderTest/NetbeansCurrent/ProjectSnippets/build/generated/src/org/apache/jsp/portfolio_005fone_jsp.java:252: error: 'else' without 'if'
else if((Boolean)request.getAttribute("UploadAttempt")) {
1 error
错误提示if
不带else
,但是我在if
之后立即放置了else
.那为什么会出错呢?
The error says if
without else
but i have placed else
immediately after if
. Then why the error?
推荐答案
您必须将它们放在同一脚本块中.只需删除结尾的%>
和开头的<%
:
You have to put them in the same script block. Just remove the ending %>
and the beginning <%
:
<% }
else if (...
这篇关于错误:否则,如果没有.但是我把它放在后面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文