javabean
package beans;
public class Student {
private String stuno;
private String stuname;
public String getStuno() {
return stuno;
}
public void setStuno(String stuno) {
this.stuno = stuno;
}
public String getStuname() {
return stuname;
}
public void setStuname(String stuname) {
this.stuname = stuname;
}
}
在JSP页面中进行导入包
<%@ page language="java" import="java.util.*" import="beans.Student" pageEncoding="utf-8"%>
//beans.Student 包名.类名
使用<JSP:useBean>动作进行实例化
<body>
<jsp:useBean id="student" class = "beans.Student"></jsp:useBean>
//创建了一个名为student的JAVAbean对象
<jsp:setProperty property="stuname" name="student" param="studentName"/>
//使用setproperty 把student中的stuname属性赋值为参数studentName传进来的值 param用来获取studentName的 值
<%=student.getStuname()%>//使用JAVA语句进行显示
</body>
http://desktop-dargq5r:8080/JS/index.jsp?studentName=rose
//在URL 中对 studentName 赋值