我是新手,请各位高手帮帮忙!
我找了javabean相关知识了,就是运行不出javabean,急啊!!!
我是先在dos环境下编译sampleBean.java,然后把sampleBean.class复制到
D:\Apache Software Foundation\Tomcat 5.5\webapps\jsp\WEB-INF\classes\bean
java源程序:
package bean;
public class sampleBean
{
private String sample="start value";
public String getSample()
{return sample;}
public void setSample(String newValue)
{ if(newValue!=null) sample=newValue;}
}
在D:\Apache Software Foundation\Tomcat 5.5\webapps\jsp下编写sample1.jsp
jsp程序:
<%@page contentType="text/html;charSet=2312"%>
<html>
<head><title>servlet使用jsp</title></head>
<jsp:useBean id="mybean" scope="application" class="bean.sampleBean"/>
<body>
<h2>使用javabean</h2>
<jsp:getProperty name="mybean" property="sample"/>
<jsp:setProperty name="mybean" property="sample" value="hhhh"/>
<jsp:getProperty name="mybean1" property="sample"/>
</body></html>
打开IE 输入http://localhost:8080/jsp/sample1.jsp
结果出错了:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Attempted a bean operation on a null object.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.jasper.JasperException: Attempted a bean operation on a null object.
org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibrary.java:601)
org.apache.jsp.sample1_jsp._jspService(sample1_jsp.java:62)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
帮我看看!非常感激!
是不是还需要一些特殊配置呢?
如能出例子,那最好了。
3q!!!!
----------------解决方案--------------------------------------------------------
试图一个BEAN操作在一个空对象上?
看一看哪有空值
----------------解决方案--------------------------------------------------------
<jsp:getProperty name="mybean1" property="sample"/>
----------------解决方案--------------------------------------------------------
我有点眉目了
原来我环境还没配置好!
[精华]Tomcat5.5.9+JSP经典配置实例
上面的精华贴对我的帮助很大!
这个网站真得很好,有很多的好人,我会常来的!!!
----------------解决方案--------------------------------------------------------
哎
白看到最后了
----------------解决方案--------------------------------------------------------
环境装好了,但运行老出现下面的错误!
The value for the useBean class attribute SimpleBean is invalid
这个错误大概会是哪里出错了
哪位高手给我一个简单的,能运行得javabean程序,环境是Tomcat+jsp
邮箱:xiezuohao2008@163.com
----------------解决方案--------------------------------------------------------
The value for the useBean class attribute SimpleBean is invalid
看一下javabean的属性,注意大小写
----------------解决方案--------------------------------------------------------
哈哈 我知道,在cmd下编译的时候你要javac -d mybean sampleBean.java
这样就会产成mybean\bean下的sampleBean.class,然后再复制过去~
----------------解决方案--------------------------------------------------------
我试了一下,好象还不行啊!
你以前一定编过javabean,发个出来看看阿!
----------------解决方案--------------------------------------------------------
建议从头学习java se
这样理解javabean就很容易了 学jsp将更轻松
如果上来就学jsp servlet javabean
越学越摸不着头脑
基础还是很重要的啊
----------------解决方案--------------------------------------------------------