方法一:
在头部添加指令引入class,然后直接在页面嵌入java代码
<%@ page import="com.zzy.bean.Book"%>
<%
Book book = new Book();
book.setId(1);
book.setAuthor("鲁迅");
book.setTitle("狂人日记");
%>
<table cellpadding="3" cellspacing="3">
<table cellpadding="3" cellspacing="3">
<tr>
<td>图书编号:</td>
<td><%= bk.getId() %></td>
</tr>
<tr>
<td>图书名称:</td>
<td><%= bk.getTitle() %></td>
</tr>
<tr>
<td>图书作者:</td>
<td><%= bk.getAuthor() %></td>
</tr>
</table>
</table>
方法二:
使用<jsp:useBean><jsp:setProperty><jsp:getProperty>动作标签
/*导入类文件*/
<jsp:useBean id="book" class="com.zzy.bean.Book"></jsp:useBean>
<jsp:setProperty property="id" name="book" value="1"></jsp:setProperty>
<jsp:setProperty property="title" name="book" value="狂人日记"></jsp:setProperty>
<jsp:setProperty property="Author" name="book" value="鲁迅"></jsp:setProperty>
<table cellpadding="3" cellspacing="3">
<tr>
<td>图书编号:</td>
<td><jsp:getProperty property="id" name="book"/><br></td>
</tr>
<tr>
<td>图书名称:</td>
<td><jsp:getProperty property="title" name="book"/><br></td>
</tr>
<tr>
<td>图书作者:</td>
<td><jsp:getProperty property="author" name="book"/><br></td>
</tr>
</table>
网友评论