Quantcast
Channel: OKWAVE 閲覧数の多い質問(Java/253)【本日】
Viewing all articles
Browse latest Browse all 68675

JSPでDBからデータ読み込みブラウザーで10件ずつ表示させたい。

$
0
0
JSPでDBからデータを表示させる事ができました、これをブラウザーで10件ずつ表示させ、次へ→、←戻る又はページ数表示で移動させたいのですが、PHPとかでは あったのですがJAVA初心者にはわかりません。 誰か教えてください、お願いします。 <%@page import="java.sql.*,MyDatabase.MyDBAccess" contentType="text/html;charset=Shift_JIS"%> <% String sel=request.getParameter("sel"); sel=new String(sel.getBytes("8859_1"),"Shift_JIS");//selectしたカテゴリーname MyDBAccess db =new MyDBAccess(); db.open(); //String str; //str=sel; ResultSet rs = db.getResultSet("select * from "+sel+""); String tableHTML ="<table border=1>"; tableHTML +="<tr bgcolor=\"#ff9933\">" +"<td><font color=\"white\">商品ID</font></td>" +"<td><font color=\"white\">画像</font></td>" +"<td><font color=\"white\">商品名</font></td>" +"<td><font color=\"white\">数量</font></td>" +"<td><font color=\"white\">タイトル</font></td>" +"<td><font color=\"white\">価格</font></td>" +"<td><font color=\"white\">説明</font></td>"; int n=0; while(rs.next()){ //int id=rs.getInt("id"); String id=rs.getString("id"); String name=rs.getString("name"); String sum=rs.getString("sum"); String price=rs.getString("price"); String title=rs.getString("title"); String detail=rs.getString("detail"); String ima=rs.getString("imagelink"); //ima=new String(ima.getBytes("8859_1"),"Shift_JIS"); String imag=("../image/"+ima); tableHTML +="<tr><td align=\"right\">"+id+"</td>" +"<td><img src="+imag+" whdth=\"120\" height=\"60\"></td>" +"<td>"+name+"</td>" +"<td>"+sum+"</td>" +"<td>"+title+"</td>" +"<td>"+price+"</td>" +"<td>"+detail+"</td></tr>"; n++; } tableHTML +="</table>"; db.close(); %> <html> <head> <title>商品在庫情報</title> </head> <body> <h1><%= sel %>の在庫一覧</h1> <%=tableHTML %> </body> </html>

Viewing all articles
Browse latest Browse all 68675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>