利用javabean封装信息并在jsp页面输出

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、运行结果

posted @ 2016-07-01 08:40  jakermk  阅读(1506)  评论(0编辑  收藏  举报