<%@page contentType="text/html; charset=GBK"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<html>
<head>
<title>edit</title>
</head>
<body bgcolor="#ffffff">
<c:if test="${empty requestScope.result}">
  <form action="editservlet?id=${requestScope.CDBean.cdId}&action=updata" method="POST">
  <table>
    <tr>
      <td>        编号
        &nbsp;
        <input type="text" name="cdId" size="2" value="${requestScope.CDBean.cdId}" readonly/>
      </td>
    </tr>
    <tr>
      <td>        名字
        &nbsp;
        <input type="text" name="cdName" value="${requestScope.CDBean.cdName}"/>
      </td>
    </tr>
    <tr>
      <td>        公司
        &nbsp;
        <input type="text" name="cdCompany" value="${requestScope.CDBean.cdCompany}"/>
      </td>
    </tr>
    <tr>
      <td>        歌手
        &nbsp;
        <input type="text" name="cdAlbum" value="${requestScope.CDBean.cdAlbum}"/>
      </td>
    </tr>
    <tr>
      <td>        类型
        &nbsp;
        <sql:setDataSource driver="com.microsoft.jdbc.sqlserver.SQLServerDriver" url="jdbc:microsoft:sqlserver://127.0.0.1:1433;databasename=MyData" user="sa" password="456852" var="db" scope="request"/>
        <sql:query var="query" dataSource="${db}">select * from CDtype</sql:query>
        <select name="cdType">
          <c:forEach var="type" items="${query.rows}">
            <c:if test="${type.display==requestScope.CDBean.cdType}">
              <option value="${type.CDtypeId}">${type.display}              </option>
            </c:if>
          </c:forEach>
          <c:forEach var="type" items="${query.rows}">
            <c:if test="${type.display!=requestScope.CDBean.cdType}">
              <option value="${type.CDtypeId}">${type.display}              </option>
            </c:if>
          </c:forEach>
        </select>
      </td>
    </tr>
    <tr>
      <td>
        <input type="submit" value="更新"/>
        <input type="button" onclick="javascript:window.close(this);" value="取消"/>
      </td>
    </tr>
  </table>
  </form>
</c:if>
<c:if test="${requestScope.result==true}">
  <center>
    <table>
      <tr>
        <td>
          <font color="red">恭喜更新成功</font>
        </td>
      </tr>
      <tr>
        <td>
          <a href="editservlet?id=${requestScope.CDBean.cdId}">重新操作</a>
        </td>
        <td>
          <a onclick="javascript:opener.location.href='oprater?action=select';javascript:window.close(this);">确认</a>
        </td>
      </tr>
    </table>
  </center>
</c:if>
<c:if test="${requestScope.result==false}">
  <center>
    <table>
      <tr>
        <td>
          <font color="red">抱歉更新失败</font>
        </td>
      </tr>
      <tr>
        <td>
          <a href="editservlet?id=${requestScope.CDBean.cdId}">重新操作</a>
        </td>
        <td>
          <a onclick="javascript:window.close(this);">离开</a>
        </td>
      </tr>
    </table>
  </center>
</c:if>
</body>
</html>
不明白其中 empty requestScope.result 是从什么地方来的

解决方案 »

  1.   

    jstl 的语法 相当于 request.getAttribute("result") == null
      

  2.   

    ${requestScope.CDBean.cdName}这个是获取名字的吗,关键是不知道这个记录是怎么查询到的,很奇怪
      

  3.   

    1、requestScope,将请求范围内的属性名和他的值进行映射,主要用于获取请求范围内的属性的值。2、${requestScope.CDBean.cdName},首先在请求范围内查找CDBean这一对象。requestScope后的点表示字啊request的范围内查找CDBean这一对象,CDBean后的点表示对用CDBean的属性cdName。3、“这个记录是怎么查询到的”,先前的程序可定调用过过类似request.setAttribute("CDBean",object)的方法,先前可定在request的范围内保存了这一对象CDBea。