id325992468526234 2021-05-29 14:52 采纳率: 33.3%
浏览 391
已结题

useBean类属性[com.lgz.pojo.People]的值无效。

 

<%@ page import="com.lgz.*" %> >
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<%
//People people = new People();
//people.setAddress();
//people.setAge();
//people.setId();
//people.setName();
%>

<jsp:useBean id="people" class="com.lgz.pojo.People" scope="page"/>
<jsp:setProperty name="people" property="address" value="sz"/>
<jsp:setProperty name="people" property="id" value="1"/>
<jsp:setProperty name="people" property="age" value="15"/>
<jsp:setProperty name="people" property="name" value="zs"/>

姓名:<jsp:getProperty name="people" property="name"/>
id:<jsp:getProperty name="people" property="id"/>
年龄:<jsp:getProperty name="people" property="age"/>
地址:<jsp:getProperty name="people" property="address"/>
</body>
</html>
package com.lgz.pojo;

//实体类 我们一般都是和数据库中的表结构一一对应
public class People {

    private int id;
    private String name;
    private int age;
    private String address;

    public People() {

    }

    public People(int id, String name, int age, String address) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.address = address;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    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;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String toString() {
        return "People{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", address='" + address + '\'' +
                '}';
    }
}
  • 写回答

3条回答 默认 最新

  • CSDN专家-Fay 2021-05-29 14:58
    关注

    我用你的代码测试了下,没有问题,你再试试!

     

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 7月12日

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿