| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 561 人关注过本帖
标题:小弟拼死也弄不明白关于
只看楼主 加入收藏
challenge
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-2-28
收藏
 问题点数:0 回复次数:5 
小弟拼死也弄不明白关于
usebean出错了

<%@ page language="java" contentType="text/html;charset=gb2312"%>
<jsp:useBean id="user" scope="page" class="com.jspdev.ch3.TestBean"/>
<jsp:setProperty name="user" property="userName" param="UserName"/>
<jsp:setProperty name="user" property="password" param="password"/>
<jsp:setProperty name="user" property="age" param="age"/>


注册成功:<br>
<hr>
使用bean属性方法:<br>
用户名:<%=user.getUserName() %><br>
密码:<%=user.getPassword() %><br>
年龄:<%=user.getAge()%><br>
<hr>
使用getProperty:<br>
用户名:<jsp:getProperty name="user" property="userName"/><br>
密码:<jsp:getProperty name="user" property="password"/><br>
年龄:<jsp:getProperty name="user" property="age"/><br>





这是网业,usebean为

ackage com.jspdev.ch3;

public class TestBean
{
public String userName;
public String password;
public int age;

public void setUserName(String name)
{
this.userName=name;
}
public void setPassword(String password)

{
this.password=password;
}
public String getUserName()
{
return this.userName;
}
public String getPassword()
{
return password;
}
public int getAge()
{
return this.age;
}
public void setAge(int age)
{
this.age=age;
}
}








可是结果为:

type Exception report

message

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

exception

org.apache.jasper.JasperException: com.jspdev.ch3.TestBean
at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:135)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:650)
at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:507)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1025)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1031)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:187)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Generator.generate(Generator.java:1891)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)


root cause

java.lang.ClassNotFoundException: com.jspdev.ch3.TestBean
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1407)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1252)
at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:133)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:650)
at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:507)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1025)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1031)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:187)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Generator.generate(Generator.java:1891)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)


这是什么错误!
2006-02-28 20:05
challenge
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-2-28
收藏
得分:0 
小弟拼死也弄不明白关于<jsp:javabean
usebean出错了

<%@ page language="java" contentType="text/html;charset=gb2312"%>
<jsp:useBean id="user" scope="page" class="com.jspdev.ch3.TestBean"/>
<jsp:setProperty name="user" property="userName" param="UserName"/>
<jsp:setProperty name="user" property="password" param="password"/>
<jsp:setProperty name="user" property="age" param="age"/>


注册成功:<br>
<hr>
使用bean属性方法:<br>
用户名:<%=user.getUserName() %><br>
密码:<%=user.getPassword() %><br>
年龄:<%=user.getAge()%><br>
<hr>
使用getProperty:<br>
用户名:<jsp:getProperty name="user" property="userName"/><br>
密码:<jsp:getProperty name="user" property="password"/><br>
年龄:<jsp:getProperty name="user" property="age"/><br>





这是网业,usebean为

package com.jspdev.ch3;

public class TestBean
{
public String userName;
public String password;
public int age;

public void setUserName(String name)
{
this.userName=name;
}
public void setPassword(String password)

{
this.password=password;
}
public String getUserName()
{
return this.userName;
}
public String getPassword()
{
return password;
}
public int getAge()
{
return this.age;
}
public void setAge(int age)
{
this.age=age;
}
}








可是结果为:

type Exception report

message

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

exception

org.apache.jasper.JasperException: com.jspdev.ch3.TestBean
at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:135)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:650)
at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:507)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1025)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1031)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:187)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Generator.generate(Generator.java:1891)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)


root cause

java.lang.ClassNotFoundException: com.jspdev.ch3.TestBean
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1407)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1252)
at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:133)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:650)
at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:507)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1025)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1031)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:187)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Generator.generate(Generator.java:1891)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)


这是什么错误!
2006-02-28 20:15
niujunze
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-3-1
收藏
得分:0 

我也不是很肯定,不过我想
不应该以"用户名:<%=user.getUserName() %>"的方式来获得属性值吧

2006-03-01 21:15
ming206
Rank: 2
来 自:重庆
等 级:等待验证会员
威 望:3
帖 子:545
专家分:7
注 册:2005-8-2
收藏
得分:0 

换种方式测试看看得行不?
<%
TestBean user=new TestBean()
//设置
user.setUserName("myname"); //任意输入测试一下
user.setPassword("myPassword");
user.setAge("myAge");
//Get取得属性
document.write("UserName="+user.getUserName()+"<br>Password="+user.getPassword()+"<br>Age="+user.getAge())
%>


外贸综合平台:E贸通
2006-03-03 00:46
ming206
Rank: 2
来 自:重庆
等 级:等待验证会员
威 望:3
帖 子:545
专家分:7
注 册:2005-8-2
收藏
得分:0 
是out.print(-------------);

外贸综合平台:E贸通
2006-03-03 01:08
bimnm
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-2-24
收藏
得分:0 
没 自己仔细看
<%@ page language="java" contentType="text/html;charset=gb2312" import="com.jspdev.ch3.TestBean.*"//在这把 javabean的包引 进来 %>
直接用试试
2006-03-07 14:50
快速回复:小弟拼死也弄不明白关于
数据加载中...
 
   



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

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