| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 663 人关注过本帖
标题:jsp+javabeans的显示小问题
取消只看楼主 加入收藏
hunkzhang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-1-16
收藏
 问题点数:0 回复次数:5 
jsp+javabeans的显示小问题

input.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>

<table width="560" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<form name="form1" method="post" action="input2.jsp">
<tr>
<td height="42" colspan="2" valign="top">测试:</td>
</tr>
<tr>
<td width="121" height="26" align="right" valign="top">性别:</td>
<td width="439" valign="top">
<input type="radio" name="gender" value="male">

<input type="radio" name="gender" value="female">

</td>
</tr>
<tr>
<td height="24" align="right" valign="top">年龄:</td>
<td valign="top"><input type="text" name="age"></td>
</tr>
<tr>
<td height="24" align="right" valign="top">体重:</td>
<td valign="top"><input type="text" name="weight"></td>
</tr>
<tr>
<td height="27" valign="top"><input type="submit" name="Submit" value="提交"></td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="158">&nbsp;</td>
<td>&nbsp;</td>
</tr></form>
</table>
</body>
</html>

input2.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id = "Calculator" class ="CalMeasure" scope="session" />
<jsp:setProperty name ="Calculator" property="*" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
你的结果:<jsp:getProperty name="Calculator" property="result" />
</body>
</html>

CalMeasure.class

import java.io.*;
public class CalMeasure {

int weight;
int age;
int result =0;//1
String gender;

public CalMeasure(){

}
public int getWeight(){
return this.weight;
}
public int getAge(){
return this.age;
}
public String getGender(){
return this.gender;
}
public int getResult(){
return calculate();//
}

public void setWeight(int weight_){
this.weight = weight_;
}
public void setAge(int age_){
this.age = age_;
}
public void setGender(String gender_){
this.gender = gender_;
}
private int calculate(){
if(this.result!=0){
return this.result;
}else{
float fltTEN = (float)(weight * 2); //2
this.result = (int)fltTEN;//2;
return this.result;//////////////
}//else
}

public static void main(String[] args) {

CalMeasure p=new CalMeasure();
System.out.println(p.calculate());
}

}//class

出现错误:
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /input2.jsp(3,0) The value for the useBean class attribute CalMeasure is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1227)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3272)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

请问是怎么回事啊?????????

搜索更多相关主题的帖子: javabeans jsp 
2007-01-16 15:07
hunkzhang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-1-16
收藏
得分:0 
去掉也不行,5555555
2007-01-16 15:36
hunkzhang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-1-16
收藏
得分:0 

那怎么用啊???可给改改不?谢谢热心人

2007-01-16 16:31
hunkzhang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-1-16
收藏
得分:0 
不懂
你的结果:<jsp:getProperty name="Calculator.calculate()" property="result" />????????
2007-01-16 17:04
hunkzhang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-1-16
收藏
得分:0 

到底怎么弄的啊

2007-01-17 09:19
hunkzhang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-1-16
收藏
得分:0 

是不是用到了JSP标签?而我没标签库?

2007-01-17 09:43
快速回复:jsp+javabeans的显示小问题
数据加载中...
 
   



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

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