SimpleBean.java

1
2
3
4
5
6
7
8
9
10
11
12
package wxy;

public class SimpleBean
{
private String message;

public SimpleBean() { ; }

public void setMessage(String mess) { message = mess; }

public String getMessage(){ return message; }
}

合适版本的javac(否则会报错)放到 网站根目录/WEB-INF/class/包路径/


JavaBean.jsp

1
2
3
4
5
6
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="wxy.*" %>
<jsp:useBean id="t1" scope="session" class="wxy.SimpleBean" />
<jsp:setProperty name="t1" property="message" value="hhh" />
<jsp:getProperty name="t1" property="message" />

修改 class 文件,需要重启Tomcat