###前提・実現したいこと
以下の構文をスクリプトレットを使わずに
記述したい。
また、記述したコードを挿入する
場所も下記に記載しておきます
###変更したいコード
<% String memo = rs11.getString("note"); if (memo == "") { %>-<% } else if (memo == null) { %>-<% } else { %><%=rs11.getString("note")%>
###挿入先JSP
<%@ page contentType="text/html; charset=UTF-8" import="java.sql.*,javax.naming.*,javax.sql.*,java.text.*,java.util.Date,java.util.Calendar"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%> <html> <sql:setDataSource var="db" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/Library" user="root" password="" /> <sql:query var="rs" dataSource="${db}"> SELECT book.book_no,book.book_name,book.note,genre.genre_name, lend.lend_date,book.state FROM book LEFT JOIN lend ON book.book_no = lend.book_no LEFT JOIN user ON user.user_no = lend.user_no LEFT JOIN genre ON book.genre_no = genre.genre_no where book.delete_flg = 0 <c:if test="${!empty param['genreNo']}"> and book.genre_no = ? <sql:param value="${param['genreNo']}" /> </c:if> ORDER BY book.book_no; </sql:query> <sql:query var="rs1" dataSource="${db}"> select * from genre </sql:query> <sql:query var="rs2" dataSource="${db}"> select book.book_no from book </sql:query> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <head> <link rel="stylesheet" type="text/css" href="css/Library.css"> <meta content="text/html; charset=UTF-8"> <title>書籍管理画面</title> </head> <body> <h2>書籍管理画面</h2> <br> <form method="POST" action="book_kanri.jsp"> <br> <form method="POST" action="book_kanri.jsp"> <p> ジャンル <select name="genreNo"> <option value="">全て</option> <c:forEach var="row" items="${rs1.rows}"> <option value=${row.genre_no}>${row.genre_name}</option> </c:forEach> </select> </p> <INPUT style="color: white; background-color: D57200;" type="submit" value="絞り込む" /> </form> <br> <br> <form method="POST" action="book_memo"> <p> 書籍ID <select name="book_no"> <c:forEach var="row" items="${rs2.rows}"> <option>${row.book_no}</option> </c:forEach> </select> </p> <div> 備考<input type="text" name="note" /> </div> <br> <INPUT style="color: white; background-color: D57200;" type="submit" value="登録" /> </form> <br> <table class="tbl_01" border="1"> <tr> <th>書籍ID</th> <th>書籍名</th> <th>ジャンル</th> <th>貸出</th> <th>貸出変更</th> <th>削除</th> <th>備考(メモ)</th> </tr> <c:forEach var="row" items="${rs.rows}"> <tr> <td>${row.book_no}</td> <td>${row.book_name}</td> <td>${row.genre_name}</td> <td><c:if test="${row.state == 1}">○</c:if> <c:if test="${row.state != 1}">×</c:if></td> <c:if test="${row.state == 1}"> <td><form method="POST" action="kano"> <input type="hidden" name="id" value=${row.book_no}> <button class="button" type="submit">不可へ</button> </form></td> </c:if> <c:if test="${row.state != 1}"> <td><form method="POST" action="huka"> <input type="hidden" name="id" value=${row.book_no}> <button class="button" type="submit">可能へ</button> </form></td> </c:if> <td><form method="POST" action="delete_book"> <input type="hidden" name="user_edit" value=${row.book_no}> <button class="button" type="submit">削除</button> </form></td> <td> ===============ここに挿入======================= </td> </tr> </c:forEach> </table> <br> <form action="kanri_mypage.jsp"> <input style="color: white; background-color: D57200;" type="submit" name="mypage" value="TOPページ"> </form> <form action="book_resurrection.jsp"> <input style="color: white; background-color: D57200;" type="submit" name="reset2" value="削除済書籍編集"> </form> <c:if test="${!empty requestScope['errorMessage']}"> <div>${requestScope['errorMessage']}</div> </c:if> </body> </html> /
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。