页面jsp展示java数据的标签

jstl核心标签

代码

package cn.itcast.estore.web.servlet;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.itcast.estore.domain.Book;
import cn.itcast.estore.service.BookService;
import cn.itcast.estore.utils.BaseServlet;

//图书模块Servlet
public class BookServlet extends BaseServlet {
    private static final long serialVersionUID = 1L;
    //展示所有分类下的图书
    public String findAll(HttpServletRequest req,HttpServletResponse resp){
        BookService bookService = new BookService();
        List<Book> list = bookService.findAll();
        req.setAttribute("list", list);
        return "/jsps/book/list.jsp";
    }

页面

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>图书列表</title>
  </head>

  <body>

<c:forEach items="${list }" var="book">
  <div class="icon">
    <a href="${pageContext.request.contextPath }/bookServlet?method=findByBid&bid=${book.bid}">
    <img src="${pageContext.request.contextPath }/${book.image}" 
    border="0" width="130" height="140"/></a>
      <br/>
    <a href="${pageContext.request.contextPath }/bookServlet?method=findByBid&bid=${book.bid}">${book.bname }</a>
  </div>
</c:forEach>
  </body>

</html>

struts标签

代码

package cn.itcast.crm.role.web;

import java.util.List;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import cn.itcast.crm.dep.business.ebi.DepEbi;
import cn.itcast.crm.dep.vo.DepModel;
import cn.itcast.crm.role.business.ebi.RoleEbi;
import cn.itcast.crm.role.vo.RoleModel;

public class RoleAction extends ActionSupport{
    public RoleModel rm = new RoleModel();
    private RoleEbi roleEbi;
    public void setRoleEbi(RoleEbi roleEbi) {
        this.roleEbi = roleEbi;
    }
    //跳转到列表
    public String list(){
        List<RoleModel> roleList = roleEbi.getAll();
        ActionContext.getContext().put("roleList", roleList);
        return "list";
    }
}

页面

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body >
<table width="100%" border="1" >
  <tr class="henglan" style="font-weight:bold;">
    <td width="6%" align="center">部门名称</td>
    <td width="6%" align="center">职务名称</td>
    <td width="7%" align="center">编辑</td>
  </tr>

  <s:iterator value="roleList" status="s">
  <tr class="tabtd${ s.count%2+1 }">
    <td align="center">${ dm.name }</td>
    <td align="center">${ name }</td>
    <td width="7%" align="center">
        <s:a action="role_toUpdate">
            <s:param name="rm.id" value="id"/>
            <img src="images/button/modify.gif" class="img">
        </s:a>
    </td>
  </tr>
  </s:iterator>
</table>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值