【汇智学堂】jsp(useBean,setProperty,getProperty)

匆匆过客 提交于 2020-02-26 02:41:08

在这里插入图片描述
Acticle:

package com.huizhi.bean;

public class Acticle {

    private int id;
    private String title;
    private String author;

    public int getId() {
        return id;
    }

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

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }
}

useBean.jsp:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <jsp:useBean id="article" class="com.huizhi.bean.Acticle"/>

    <jsp:setProperty name="article" property="id" value="520"/>
    <jsp:setProperty name="article" property="title" value="关于学生教育"/>
    <jsp:setProperty name="article" property="author" value="人文雷老师"/>

    <p>
        编号:<jsp:getProperty name="article" property="id"/><br>
        标题:<jsp:getProperty name="article" property="title"/><br>
        作者:<jsp:getProperty name="article" property="author"/>
    </p>

</body>
</html>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!