请各位大侠帮忙看看··我的JSP+JBean的猜数字程序有什么问题没?为什么我运行起来是500错误!
在tomcat里的webapps目录下建立myapp下建立number.jsp,同时建立文件夹WEB-INF/classes。在建立NumberG.java。
以下number.jsp的内容————
<jsp:useBean id="number" class="NumberG" scope="session" />
<jsp:setProperty name="number" property="*" />
<html>
<head>
<title>张旭-新人上手2部分——任务B</title>
</head>
<body>
<%
if(number.getNumG()==0)
{
%>
<B> 你猜我年纪多大了?(1-100)</B>
<form method=post>
<input type=text name="guess">
<input type=submit value=submit name="Start">
</form>
<%
}
else if(number.getSunum())
{ %>
真棒,你猜对了!你一共猜了<%=number.getNumG()%>次。
点击 <a href=index.jsp>重新返回?</a>
<%
}
else
{
%>
<br>
猜的不错, 但还不对. 这次 <%=number.getOutkey()%>! 你已经猜了 <%=number.getNumG()%>次。
</br>
<br>
再猜一次吧!
</br>
<form method=post><input type=text name="guess">
<input type=submit value=submit name="Start">
</form>
<%
}
%>
</body>
</html>
——————————————————————————————————————————————————
以下是Number.java 的内容
import java.util.*;
import java.io.*;
public class NumberG implements Serializable {
private static final long serialVersionUID=1L;
private int innum,numG;
private boolean sunum;
private String outkey;
private Random random=new Random();
public NumberG() {
reset();
}
public int getInnum()
{
return innum;
}//取出的值
public void setAnswer(int innum)
{
this.innum=innum;
}//放入answer的值
public boolean getSunum() {
return sunum;
}
public void setSunum(boolean sunum) {
this.sunum = sunum;
}
public String getOutkey() {
return "" +outkey;
}
public void setOutkey(String outkey){
this.outkey=outkey;
}
public int getNumG() {
return numG;
}
public void setNumG(int numG)
{
this.numG=numG;
}
public void setGuess(String guess) {
numG++;
int g;
try {
g = Integer.parseInt(guess);
}
catch (
NumberFormatException e) {
g = -1;
}
if (g == innum) {
sunum = true;
}
else if (g == -1) {
outkey = "输入有误,请您输入一个100以内的整数。!";
}
else if (g <innum) {
outkey = "高了";
}
else if (g > innum) {
outkey = "低了";
}
}
public void reset() {
innum = Math.abs(new Random().nextInt() % 100)+1;
sunum = false;
numG = 0;
}
}
——————————————————————————————————————
在WEB-INF下的web.xml内插入以下注释
<servlet>
<servlet-name>NumberG</servlet-name>
<servlet-class>NumberG</servlet-class>
</servlet>
<servlet-mapping&g