2 chenlxhf chenlxhf 于 2016.04.19 15:56 提问

新手,useBean问题,求帮忙

jsp页面

 <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!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=UTF-8">
<title>useBean 测试页面</title>
</head>
<body>
    <h1>useBean测试页面</h1>
    <jsp:useBean id="person" class="test.Person" scope="page"></jsp:useBean>
    <jsp:setProperty property="name" name="person" value="xiaowang"/>
    <jsp:setProperty property="age" name="person" value="65" />
    <jsp:getProperty property="name" name="person"/><br>
    <jsp:getProperty property="age  " name="person"/><br>
</body>
</html>

javaBean代码

 package test;

public class Person {
    private String name;
    private int age;
    public Person(){}
    public Person(String name,int age){
        this.name=name;
        this.age=age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }

}

运行后结果:

要么就是找不到类,要么就是属性值找不到。求大神指教
type Exception report

message Cannot find any information on property 'age ' in a bean of type 'test.Person'

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

exception

org.apache.jasper.JasperException: Cannot find any information on property 'age ' in a bean of type 'test.Person'
org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:825)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1144)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1140)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2444)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2450)
org.apache.jasper.compiler.Node$Root.accept(Node.java:474)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392)
org.apache.jasper.compiler.Generator.generate(Generator.java:3581)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:251)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

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


3个回答

hongweibing1
hongweibing1   2016.04.19 16:11
已采纳

首先你的age后面多了个空格,太粗心了

CSDNXIAON
CSDNXIAON   2016.04.19 16:21

TSP问题,求帮忙。
----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!

chenlxhf
chenlxhf   2016.04.19 17:13

谢谢你!!一改过了就可以!真的是我太粗心了

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!