利用javabean封装信息并在jsp页面输出
Posted jakermk
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了利用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、运行结果
以上是关于利用javabean封装信息并在jsp页面输出的主要内容,如果未能解决你的问题,请参考以下文章