Bean/New.java

package Bean;

public class New {
    private String name;
    private String id;

    public New(){

    }

    public New(String name, String id) {
        this.name = name;
        this.id = id;
    }

    public String getName() {
        return name;
    }

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

    public String getId() {
        return id;
    }

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


存入数据:setel

<%@ page import="Bean.New" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/4/6
  Time: 15:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    New news=new New();
    request.setAttribute("新疆棉",6273);
%>
<jsp:forward page="getel.jsp"/>
</body>
</html>


取出数据:getel

<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/4/6
  Time: 15:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
${news.name}:${news.id}
</body>
</html>

解析:新建Java类”New”,定义数据值类型以及数据存取方式
“setel”存入数据,新建New赋值给news,存入数据”新疆棉”,ID为”6273″,请求转发方式到获取数据页面”getel”。
getel页面获取数据,因为setel是请求转发,将getel页面内容拿到setel页面来做输出。
资源下载此资源下载价格为1摩拉,请先
博主Qq:2807306273