1、javabean代码
package lianxi; public class lianxi4 { private String name; private String xingbie; private int nianling; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getXingbie() { return xingbie; } public void setXingbie(String xingbie) { this.xingbie = xingbie; } public int getNianling() { return nianling; } public void setNianling(int nianling) { this.nianling = nianling; } }
2、jsp输出页面代码
<%@page import="lianxi.xinxi"%> <%@ 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>Insert title here</title> </head> <body> <% xinxi s=new xinxi(); s.setName("李四"); s.setAge(23); s.setNum(2348988); s.setAddress("山东省"); out.print("姓名:"+s.getName()); out.print("<br>学号:"+s.getNum()); out.print("<br>年龄:"+s.getAge()); out.print("<br>地址:"+s.getAddress()); %> </body> </html>
3、运行结果
时间: 2024-10-16 15:13:35