bean的问题

showerXP 2003-10-16 08:34:04
jsp1.jsp
<%@ page contentType="text/html; charset=GBK" %>

<html>
<head>
<title>
jsp1
</title>
</head>
<jsp:useBean id="jsp1BeanId" scope="session" class="first.Jsp1Bean" />
<jsp:setProperty name="jsp1BeanId" property="*"/>
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
</h1>
<form method="post" action=jsp1.jsp>
<br>Enter new value1 : <input name="sample" type="text"><br>
<br>Enter new value2 : <input name="sample2" type="text"><br>
<br><br>
<input type="submit" name="Submit" value="Submit">
<input type="reset" value="Reset">
<br>
Value1 of Bean property is :<jsp:getProperty name="jsp1BeanId" property="sample1"/>
Value1 of Bean property is :<jsp:getProperty name="jsp1BeanId" property="sample2"/> //没有它就不会出错!!!!!!!!!!!!!!!!!!!!
</form>
</body>
</html>


first.Jsp1Bean

package first;

import java.io.*;

public class Jsp1Bean implements Serializable
{
private String sample = "Start value";
private String sample2 = "Start value2";
//Access sample property
public String getSample() {
return sample;
}
//Access sample property
public void setSample(String newValue) {
if (newValue!=null) {
sample = newValue;
}
}
public String getSample2() {
return sample2;
}
//Access sample property
public void setSample2(String newValue) {
if (newValue!=null) {
sample2 = newValue;
}
}

}


"jsp3.jsp": org.apache.jasper.JasperException: Cannot find any information on property 'sample2' in a bean of type 'first.Jsp1Bean'
代码很简单的.大家仔细看看为什么?

还有在jb9下怎么对单个的.jsp文件调试?发现它总是会把所有jsp文件编译一编。
...全文
31 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ladofwind 2003-11-14
  • 打赏
  • 举报
回复
上面写的代码看不出错误!
是原本copy过来的吗?
salx 2003-11-14
  • 打赏
  • 举报
回复
哦对scope也没有
salx 2003-11-14
  • 打赏
  • 举报
回复
是这样的:用property="*" 是把所有属性均由本页面表单的同名参数来设置,若没有对应的则不设置。所以你用了sample,但sample2并没有被付值,这个属性附的是同为sample的值。
leier1979 2003-11-14
  • 打赏
  • 举报
回复
scope="page"呢
showerXP 2003-11-14
  • 打赏
  • 举报
回复
都块一个,自己顶。就是想看看为什么?
showerXP 2003-10-19
  • 打赏
  • 举报
回复
不好意思,有点笔误,这里的sample1其实就是sample,是我写错了。
我知道提示是说没有sample2。但是我在jsp中加入<%out.print jsp1BeanId.getSample2%>都可以正确的打印出借过来。正是可恶。就这么一点代码都仔细察了一个上午了。
indeed 2003-10-17
  • 打赏
  • 举报
回复
看了看你的代码,好像没有sample1这个变量啊,你的bean只有sample和sample2这两个变量的
indeed 2003-10-17
  • 打赏
  • 举报
回复
mark.......

在first.Jsp1Beanj中没有sample2这个变量啊,错误已经写的很清楚了,仔细查查代码,应该不难
showerXP 2003-10-17
  • 打赏
  • 举报
回复
up

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧