首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

jsp:useBean 有关问题

2013-12-04 
jsp:useBean 问题在看轻量级JavaEE 开发,顺手练了下面这个例子。结果出错,搞了一个晚上都没搞定。我伤不起啊

jsp:useBean 问题
在看轻量级JavaEE 开发,顺手练了下面这个例子。结果出错,搞了一个晚上都没搞定。我伤不起啊。求大神指导。我以前做C++开发的,突然想看看java web开发。结果配置问题搞死了。。哎。。


    <!-- if use default package, just need to specific class name -->
    
    <jsp:useBean class="com.web01.jsp.Person" id="peo" scope="session" />
    
    <jsp:setProperty name="peo" property="name" value="chcucl" />
    <jsp:setProperty name="peo" property="age"  value="28" />
    
    <jsp:getProperty name="peo" property="name" /> <br/>
    <jsp:getProperty name="peo" property="age" />


HTTP Status 500 - /WebContent/jsp01.jsp (line: 28, column: 4) The value for the useBean class attribute com.web01.jsp.Person is invalid.


type Exception report

message /WebContent/jsp01.jsp (line: 28, column: 4) The value for the useBean class attribute com.web01.jsp.Person is invalid.

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

exception
org.apache.jasper.JasperException: /WebContent/jsp01.jsp (line: 28, column: 4) The value for the useBean class attribute com.web01.jsp.Person is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:276)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:108)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1241)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1163)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2359)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2359)
org.apache.jasper.compiler.Generator.generate(Generator.java:3515)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:606)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:277)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Unknown Source)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:309)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:169)
java.security.AccessController.doPrivileged(Native Method)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:277)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Unknown Source)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:309)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:249) javaee
[解决办法]
好久没用这个了
Person这个bean 你在页面顶部有把包引用进来么
------解决方案--------------------


引用:
Quote: 引用:

好久没用这个了
Person这个bean 你在页面顶部有把包引用进来么
有的,已经引用进来了。


引用进来的话  你把包名去掉试试
[解决办法]
Person必须不能是抽象,必须有一个 public、无参的构造器。
包名和类名称大小写敏感。

检查一下吧
[解决办法]
引用:
Quote: 引用:

Person必须不能是抽象,必须有一个 public、无参的构造器。
包名和类名称大小写敏感。

检查一下吧
我都有啊:


package com.web01.jsp;

public class Person 
{
private String name;
private int age;

public Person() 
{
}

public Person(String name, int age) 
{
this.name = name;
this.age = age;
}

public void setName(String name) 
{
this.name = name;
}
public String getName() 
{
return this.name;
}

public void setAge(int age) 
{
this.age = age;
}
public int getAge()
{
return this.age;
}
}


重启下服务器试一下。有可能是缓存问题
[解决办法]
引用:
Quote: 引用:

Quote: 引用:

Quote: 引用:

Person必须不能是抽象,必须有一个 public、无参的构造器。
包名和类名称大小写敏感。

检查一下吧
我都有啊:


package com.web01.jsp;

public class Person 
{
private String name;
private int age;

public Person() 
{
}

public Person(String name, int age) 
{
this.name = name;
this.age = age;
}

public void setName(String name) 
{
this.name = name;
}
public String getName() 
{
return this.name;
}

public void setAge(int age) 
{
this.age = age;
}
public int getAge()
{
return this.age;
}
}


重启下服务器试一下。有可能是缓存问题
我都重启N次了,都不行。伤不起啊。

伤不起,代码没问题。
你把项目clean一下试一下。
project -> clean

热点排行