当前位置:编程学习 > JAVA >>

java web 图片浏览

根据从数据库里获取到的图片,显示在页面上,并且可以上一页下一页的点击,类似于pdf那样的。也可以说是图片浏览器  有谁做过吗? 图片 浏览器 数据库 PDF Java Web --------------------编程问答-------------------- 数据库放的图片路径吧,直接放图片不好
至于翻页显示,
      import java.util.Vector;
        public class PageBean
        {
                public int curPage;                  //当前是第几页
                public int maxPage;                //一共有多少页
                public int maxRowCount;                //一共有多少行
                public int rowsPerPage=5;        //每页多少行
                public java.util.Vector        data;        //本页要显示的资料
                public PageBean()
                {}
                public void countMaxPage()          //根据总行数据计算总页数
                {
                        if (this.maxRowCount % this.rowsPerPage==0)
                        {
                                this.maxPage=this.maxRowCount/this.rowsPerPage;
                        }
                        else
                        {
                                this.maxPage=this.maxRowCount/this.rowsPerPage+1;
                        }
                }

                public Vector getResult ()        //返回页面中的数据
                {
                        return this.data;
                }

                public PageBean(ContactBean contact) throws Exception         //构造方法
                {
                        this.maxRowCount=contact.getAvailableCount();
                        this.date=contact.getResult();
                        this.countMaxPage();
                }
        }

  [2] ContactBean是具体业务相关的Bean
        import java.util.*;
        import java.sql.*;
        public class ContactBean
        {
                private Connection con;
                Vector v;
                public ContactBean()
                {
                        conn=DatabaseConn.getConnection();        //得到数据库连接
                        v=new Vector();
                }
        //查找要查询的记录数
                public int getAvailableCount() throws Exception
                {
                        int ret=0;
                        Statement stmt=conn.createStatement();
                        String strSQL="select cou
--------------------编程问答-------------------- 百度  jquery  幻灯片效果   应该能搜到很多 --------------------编程问答--------------------
引用 1 楼 qiyuexuel 的回复:
数据库放的图片路径吧,直接放图片不好
至于翻页显示,


Java code
?



1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253

      import java.util.Vector;         public ……

恩恩,放的是图片的路径,后台处理翻页我知道,就是不知道前台显示是怎么做的 --------------------编程问答--------------------
引用 3 楼 wnn654321 的回复:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253

      import……

给你个链接,简单实现分页 --------------------编程问答-------------------- 首先我想说图片存入数据库,很不专业。
第二个问题可以归类为图片从数据读取问题。
然后是如何翻页问题。 --------------------编程问答-------------------- 找找jquery插件吧 --------------------编程问答--------------------
引用 5 楼 mutou19870410 的回复:
首先我想说图片存入数据库,很不专业。
第二个问题可以归类为图片从数据读取问题。
然后是如何翻页问题。

恩。。存到数据库里的是地址。。主要就是那个鼠标滑动的效果,下一页上一页实现是没问题的。 --------------------编程问答-------------------- struts2 实现
struts.xml  ----------------------------->>

<action name="bigPhoto" class="photoAction" method="bigPhoto">
            <result type="stream">
             <param name="bufferSize">1024</param>
            </result>
</action>

jsp  ---------------------------------->
<img width="500" height="360" src="bigPhoto?photo.fpPhotoId=<s:property value='photo.fpPhotoId'/>" />

action --------------------------------->
public class PhotoAction extends ActionSupport {
  private Photo photo;
  private File image;
  private ByteArrayInputStream inputStream;

  public String bigPhoto() {
photo = photoBiz.findPhotoByPhotoId(photo);
                                                       //数据库取的byte[]
inputStream = new ByteArrayInputStream(photo.getFpContent());
return SUCCESS;
}

//省略getter setter
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,