chenlxhf 2016-04-19 07:56 采纳率: 66.7%
浏览 1366
已采纳

新手,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.


  • 写回答

2条回答

  • hongweibing1 2016-04-19 08:11
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 汇编语言除法溢出问题
  • ¥50 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗