• c:forEach传递参数(jsp)


    1、模型层

    /**
     * @Title:Vote.java
     * @Package:com.you.vote.domain
     * @Description:投票主题对象
     * @author:Youhaidong(游海东)
     * @date:2013-8-3 上午9:48:21
     * @version V1.0
     */
    package com.you.vote.domain;
    
    import java.io.Serializable;
    
    /**
     * 类功能说明
     * 类修改者 修改日期
     * 修改说明
     * <p>Title:Vote.java</p>
     * <p>Description:游海东个人开发</p>
     * <p>Copyright:Copyright(c)2013</p>
     * @author:游海东
     * @date:2013-8-3 上午9:48:21
     * @version V1.0
     */
    public class Vote implements Serializable {
    
    	/**
    	 * @Fields  serialVersionUID:序列化
    	 */
    	private static final long serialVersionUID = 1L;
    	
    	//投票主题编号
    	private Integer voteId;
    	//投票主题
    	private String title;
    	//创建时间
    	private String createDate;
    	//投票类型
    	private Integer type;
    	//是否公布
    	private Integer publish;
    	//管理员编号
    	private Integer adminId;
    	
    	/**
    	 * <p>Title:</p>
    	 * <p>Description:无参构造函数</p>
    	 */
    	public Vote() {
    		super();
    	}
    
    	/**
    	 * <p>Title:</p>
    	 * <p>Description:有参构造函数</p>
    	 * @param title
    	 * @param createDate
    	 * @param type
    	 * @param publish
    	 * @param adminId
    	 */
    	public Vote(String title, String createDate, Integer type, Integer publish,
    			Integer adminId) {
    		super();
    		this.title = title;
    		this.createDate = createDate;
    		this.type = type;
    		this.publish = publish;
    		this.adminId = adminId;
    	}
    
    	/**
    	 * @return the voteId
    	 */
    	public Integer getVoteId() {
    		return voteId;
    	}
    
    	/**
    	 * @param voteId the voteId to set
    	 */
    	public void setVoteId(Integer voteId) {
    		this.voteId = voteId;
    	}
    
    	/**
    	 * @return the title
    	 */
    	public String getTitle() {
    		return title;
    	}
    
    	/**
    	 * @param title the title to set
    	 */
    	public void setTitle(String title) {
    		this.title = title;
    	}
    
    	/**
    	 * @return the createDate
    	 */
    	public String getCreateDate() {
    		return createDate;
    	}
    
    	/**
    	 * @param createDate the createDate to set
    	 */
    	public void setCreateDate(String createDate) {
    		this.createDate = createDate;
    	}
    
    	/**
    	 * @return the type
    	 */
    	public Integer getType() {
    		return type;
    	}
    
    	/**
    	 * @param type the type to set
    	 */
    	public void setType(Integer type) {
    		this.type = type;
    	}
    
    	/**
    	 * @return the publish
    	 */
    	public Integer getPublish() {
    		return publish;
    	}
    
    	/**
    	 * @param publish the publish to set
    	 */
    	public void setPublish(Integer publish) {
    		this.publish = publish;
    	}
    
    	/**
    	 * @return the adminId
    	 */
    	public Integer getAdminId() {
    		return adminId;
    	}
    
    	/**
    	 * @param adminId the adminId to set
    	 */
    	public void setAdminId(Integer adminId) {
    		this.adminId = adminId;
    	}	
    
    }
    

    2、JSP传递参数(错误)

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>表格</title>
    	<meta http-equiv="pragma" content="no-cache">
    	<meta http-equiv="cache-control" content="no-cache">
    	<meta http-equiv="expires" content="0">    
    	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    	<meta http-equiv="description" content="This is my page">
    	<!--
    	<link rel="stylesheet" type="text/css" href="styles.css">
    	-->
      </head>
      
      <body>
        <form action="">
           <table>
              <tr>
                <th>投票主题编号</th>
                <th>投票主题</th>
                <th>创建时间</th>
                <th>投票类型</th>
                <th>是否公布</th>
                <th>管理员编号</th>
              </tr>
              <c:forEach items="${voteList}" var="vote">
                 <tr>
                   <td>${vote.getVoteId}</td>
                   <td>${vote.getTitle}</td>
                   <td>${vote.getCreateDate}</td>
                   <td>${vote.getType}</td>
                   <td>${vote.getPublish}</td>
                   <td>${vote.getAdminId}</td>
                 </tr>
              </c:forEach>
           </table>
        </form>
      </body>
    </html>
    

    3、JSP传递参数(正确)

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>表格</title>
    	<meta http-equiv="pragma" content="no-cache">
    	<meta http-equiv="cache-control" content="no-cache">
    	<meta http-equiv="expires" content="0">    
    	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    	<meta http-equiv="description" content="This is my page">
    	<!--
    	<link rel="stylesheet" type="text/css" href="styles.css">
    	-->
      </head>
      
      <body>
        <form action="">
           <table>
              <tr>
                <th>投票主题编号</th>
                <th>投票主题</th>
                <th>创建时间</th>
                <th>投票类型</th>
                <th>是否公布</th>
                <th>管理员编号</th>
              </tr>
              <c:forEach items="${voteList}" var="vote">
                 <tr>
                   <td>${vote.voteId}</td>
                   <td>${vote.title}</td>
                   <td>${vote.createDate}</td>
                   <td>${vote.type}</td>
                   <td>${vote.publish}</td>
                   <td>${vote.adminId}</td>
                 </tr>
              </c:forEach>
           </table>
        </form>
      </body>
    </html>
    


  • 相关阅读:
    linux kernel的一些参数设
    多个会话引起唯一键冲突时(enq:TX-row lock contention,mode=4)
    位图索引冲突引发TX锁争用时,则等待enq:TX-row lock conention.
    多个会话修改相同行时(enq: TX-row lock contention,mode=6)
    设置Libevent库
    Oracle INITRANS和MAXTRANS
    基于事件的开源网络库—libevent:应用介绍
    巧妙的用IN替代关联后去从
    Error creating bean with name 'com.you.user.dao.StudentDaoTest': Injection of autowired dependencies
    java.lang.IllegalStateException: Failed to load ApplicationContext
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13315731.html
Copyright © 2020-2023  润新知