| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1070 人关注过本帖
标题:[求助],怪事!!!老大,帮 一帮呀
只看楼主 加入收藏
tqtbj
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2004-8-1
收藏
 问题点数:0 回复次数:3 
[求助],怪事!!!老大,帮 一帮呀

<% if(numGuess.getSuccess())%> <% { %> Congratulation! You got it And after just<%=numGuess.getNumGuesses()%>tries.<p> <% numGuess.setInit(); %> Care to <a href="numGuess.jsp">try again</a>? <% } %> <% else if(numGuess.getNumGuesses()==0)%> <% { %> Welcome to the Number Guess game.<p> I'm thinking of a number between 1 and 100.<p> <form method="get"> What's your guess?><input type="text" name="guess"> <input type="submit" value="Submit"> </form> <% }else{ %> Good guess,but nope. Try<b><%=numGuess.getHint()%></b> You have made<%=numGuess.getNumGuesses()%>guesses.<p> I'm thinking of a number between 1 and 100.<p> <form method=get> What's your guess?<input type=text name=guess> <input type=submit value="Submit"> </form> <% } %>

怎么总是报错呀

[javac] C:\Tomcat 4.1\work\Standalone\localhost\test\numGuess_jsp.java:81: 'else' without 'if' [javac] else if(numGuess.getNumGuesses()==0) [javac] ^ [javac] C:\Tomcat 4.1\work\Standalone\localhost\test\numGuess_jsp.java:91: 'else' without 'if' [javac] }else{ [javac] ^ [javac] 2 errors

[此贴子已经被作者于2004-08-12 01:19:49编辑过]

搜索更多相关主题的帖子: 怪事 老大 
2004-08-12 00:23
tqtbj
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2004-8-1
收藏
得分:0 

完整的代码:

<%@ page contentType="text/html;charset=gb2312" %> <%@ page import="num.numGress" %> <jsp:useBean id="numGuess" scope="session" class="num.numGuess" /> <jsp:setProperty name="numGuess" property="*" /> <html> <head> <title>测试</title> <head> <body bg="white"> <font size="4"> <% if(numGuess.getSuccess())%> <% { %> Congratulation! You got it And after just<%=numGuess.getNumGuesses()%>tries.<p> <% numGuess.setInit(); %> Care to <a href="numGuess.jsp">try again</a>? <% } %> <% else if(numGuess.getNumGuesses()==0)%> <% { %> Welcome to the Number Guess game.<p> I'm thinking of a number between 1 and 100.<p> <form method="get"> What's your guess?><input type="text" name="guess"> <input type="submit" value="Submit"> </form> <% }else{ %> Good guess,but nope. Try<b><%=numGuess.getHint()%></b> You have made<%=numGuess.getNumGuesses()%>guesses.<p> I'm thinking of a number between 1 and 100.<p> <form method=get> What's your guess?<input type=text name=guess> <input type=submit value="Submit"> </form> <% } %> </font> </body> </html>

其中numGuess.java:

package num; import java.util.*;

public class numGuess { private int answer; file://private int g; private int numGuesses; file://private String guess; private String hint; private boolean success; public numGuess() { setInit(); } public void setGuess(String guess) { numGuesses++; int g; try { g=Integer.parseInt(guess); }catch(Exception e) { g=-1; } if(g==answer) { success=true; } else if(g==-1) { hint="a number next time"; } else if(g>answer) { hint="lower"; } else { hint="higher"; } } public boolean getSuccess() { return success; } public String getHint() { return hint; } public int getNumguesses() { return numGuesses; } public void setInit() { answer=Math.abs(new Random().nextInt()%100)+1; success=false; numGuesses=0; } }

2004-08-12 00:26
tempnetbar
Rank: 2
等 级:新手上路
威 望:4
帖 子:582
专家分:4
注 册:2004-5-5
收藏
得分:0 
乍一看好像没问题,不过我也没弄过JSP不过有一点你不知道注意了没有,tomcat服务器重启了吗?我曾经帮过一个朋友,他就是没有重启所以没有加载最新的类,导致怎么改都是错

相信勤能补拙! 喜欢用好用的就永远学不到有用的。
2004-08-12 13:36
zlsunnan
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2004-8-13
收藏
得分:0 
好像是程序的问题吧 再仔细看看吧

2004-08-13 17:40
快速回复:[求助],怪事!!!老大,帮 一帮呀
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011311 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved