怎样把jiavabean里面数组传到jsp页面中显示出来
若以下回答无法解决问题,邀请你更新回答
1个回答
展开全部
例://建立类rmg.student
package rmg;
public class student {
private long classNo;
private String name;
private int age;
private boolean sexy;
public student() { //构造函数
classNo=970431;
name="ZZZl";
age=34;
sexy=true;
}
public long getClassNo() {
return classNo;
}
public void setClassNo(long no) {
this.classNo=no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name=name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age=age;
}
public boolean getSexy() {
return sexy;
}
public void setSexy(boolean sexy) {
this.sexy=sexy;
}
}
<html>
<body>
<%-- 引用自己编写的javaBean生成的bean组件 --%>
<jsp:useBean id="student" scope="application" class="rmg.student" />
<%=student.getname()%><br>
<% student.setname("cong"); %>
<%-- 用getProperty动作来返回bean组件的属性值 --%>
<jsp:getProperty name="student" property="classNo" /> <br>
<jsp:getProperty name="student" property="name" /> <br>
<jsp:getProperty name="student" property="age" /> <br>
<jsp:getProperty name="student" property="sexy" /> <br>
<%-- 取属性值 --%>
<%=student.getClassNo() %> <br>
<%=student.getName() %> <br>
<%=student.getAge() %> <br>
<%--引用Java类库中生成的bean组件 --%>
<jsp:useBean id="date" scope="session" class="java.util.Date" />
<%=date%><br>
</body>
</html>
<%=student.getSexy() %> <br>
package rmg;
public class student {
private long classNo;
private String name;
private int age;
private boolean sexy;
public student() { //构造函数
classNo=970431;
name="ZZZl";
age=34;
sexy=true;
}
public long getClassNo() {
return classNo;
}
public void setClassNo(long no) {
this.classNo=no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name=name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age=age;
}
public boolean getSexy() {
return sexy;
}
public void setSexy(boolean sexy) {
this.sexy=sexy;
}
}
<html>
<body>
<%-- 引用自己编写的javaBean生成的bean组件 --%>
<jsp:useBean id="student" scope="application" class="rmg.student" />
<%=student.getname()%><br>
<% student.setname("cong"); %>
<%-- 用getProperty动作来返回bean组件的属性值 --%>
<jsp:getProperty name="student" property="classNo" /> <br>
<jsp:getProperty name="student" property="name" /> <br>
<jsp:getProperty name="student" property="age" /> <br>
<jsp:getProperty name="student" property="sexy" /> <br>
<%-- 取属性值 --%>
<%=student.getClassNo() %> <br>
<%=student.getName() %> <br>
<%=student.getAge() %> <br>
<%--引用Java类库中生成的bean组件 --%>
<jsp:useBean id="date" scope="session" class="java.util.Date" />
<%=date%><br>
</body>
</html>
<%=student.getSexy() %> <br>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询