这是我的web页面代码:<%@ page contentType="text/html;charset=gb2312" %>
<html>
<head>
</head>
<body>
<jsp:useBean id = "gm" class = "bean.Guess1" scope = "session"/>
<jsp:setProperty name ="gm" property = "*"/>
<form action = "game1.jsp" method = "get">
请输入数字:<input type = "text" name = "in"><input type = "submit" name = "submint" value = "提交">
</form>
<br>结果:<jsp:getProperty name = "gm" property = "record"/>
<br><jsp:getProperty name = "gm" property = "in"/>
<br><jsp:getProperty name = "gm" property = "round"/>
</body></html>下面是我的javabean代码:
package bean;
import java.io.*;
import java.util.Random;
public class Guess1
{
int in;
public String record;
int round;
int conter;
public Guess1()
{
this.reset();
}
public void reset()
{
this.setRound();
}
public void setRound()
{
Random rd = new Random();
this.round = 1+rd.nextInt(100);
this.conter = 0;
}
public int getRound()
{
return this.round;
}
public void setIn(String in)
{
this.in =Integer.parseInt(in);
this.conter++;
if(this.in==this.round)
{
this.record = "恭喜你,对了";
this.reset();
}
else if (this.in>this.round)
this.record = "大了";
else if (this.in<this.round)
this.record = "小了";
}
public int getIn()
{
return this.in;
}
public int getConter()
{
return this.conter; }
public String getRecord()
{
return this.record;
}
}
各位帮我看看什么的问题,调得头都大了。好像是in值传不过去。等一系列问题。
<html>
<head>
</head>
<body>
<jsp:useBean id = "gm" class = "bean.Guess1" scope = "session"/>
<jsp:setProperty name ="gm" property = "*"/>
<form action = "game1.jsp" method = "get">
请输入数字:<input type = "text" name = "in"><input type = "submit" name = "submint" value = "提交">
</form>
<br>结果:<jsp:getProperty name = "gm" property = "record"/>
<br><jsp:getProperty name = "gm" property = "in"/>
<br><jsp:getProperty name = "gm" property = "round"/>
</body></html>下面是我的javabean代码:
package bean;
import java.io.*;
import java.util.Random;
public class Guess1
{
int in;
public String record;
int round;
int conter;
public Guess1()
{
this.reset();
}
public void reset()
{
this.setRound();
}
public void setRound()
{
Random rd = new Random();
this.round = 1+rd.nextInt(100);
this.conter = 0;
}
public int getRound()
{
return this.round;
}
public void setIn(String in)
{
this.in =Integer.parseInt(in);
this.conter++;
if(this.in==this.round)
{
this.record = "恭喜你,对了";
this.reset();
}
else if (this.in>this.round)
this.record = "大了";
else if (this.in<this.round)
this.record = "小了";
}
public int getIn()
{
return this.in;
}
public int getConter()
{
return this.conter; }
public String getRecord()
{
return this.record;
}
}
各位帮我看看什么的问题,调得头都大了。好像是in值传不过去。等一系列问题。
解决方案 »
- 标签问题求助
- 怎么读取access数据库中ole数据类型 急!
- 在bean中链接,查询数据库,怎么关闭链接?
- 老规矩,24小时结帖哦~~struts调用hibernate
- 求教,我应该在构造函数中打开数据库连接还是每次用的时候打开它?
- 求救!!如何在jbuilder中使用jspSmartUpload,因为某些原因必须使用tomcat4.0,请问如何配置??
- jbuilderx与weblogic!在win 2000高级服务器下怎么配置啊??
- 包 javax.servlet.jsp.* 不在tomcat5.* 里??
- 急等救命,论文马上就要交了
- 各位,在哪儿能下载Apache Web Server (1.3以上)?
- 谷歌解析翻译url问题
- Exception in thread "main" java.lang.OutOfMemoryError: Java heap space怎么捕获他
<jsp:setProperty name ="gm" property = "*"/>
</jsp:useBean>