如题

解决方案 »

  1.   

    一段读取本地文件,然后输出的代码(File,JSP)
      

  2.   

    我是这样写的String pathStr = "E://Company/WebRoot/images/";
    String w = request.getParameter("pictrue");
    FileInputStream fis = new FileInputStream(w);
    JPEGImageDecoder jp = JPEGCodec.createJPEGDecoder(fis);
    BufferedImage image = jp.decodeAsBufferedImage();
    FileOutputStream os = new FileOutputStream(pathStr + pic);


    JPEGImageEncoder en = JPEGCodec.createJPEGEncoder(os);
    en.encode(image);
    fis.close();
    os.close();
      

  3.   

    1.你到底要什么
    2.为什么要用流,你要展示什么
    3.<img src=图片/>
    4.你贴出代码后想说什么
      

  4.   

    import java.io.File;
    import java.io.FileOutputStream;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.image.BufferedImage;import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGImageEncoder;public class JpgTest {public void jpgTset() throws Exception{
    File _file = new File("1.jpg"); //读入文件
    Image src = javax.imageio.ImageIO.read(_file); //构造Image对象
    int wideth=src.getWidth(null); //得到源图宽
    int height=src.getHeight(null); //得到源图长
    BufferedImage tag = new BufferedImage(wideth/2,height/2,BufferedImage.TYPE_INT_RGB);
    tag.getGraphics().drawImage(src,0,0,wideth/2,height/2,null); //绘制缩小后的图
    FileOutputStream out=new FileOutputStream("newfile.jpg"); //输出到文件流
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    encoder.encode(tag); //JPEG编码
    out.close();
    }public static void main(String[] args){
    try{
    new JpgTest().jpgTset();
    }catch(Exception e){
    e.printStackTrace();
    }
    }
    }
    楼主改一下就可以了
      

  5.   

    描述的还是不清楚
    1你的图片是从客户端上传到服务端的
    2你的图片在服务端用ie可以显示
    3你的图片在客户端不能用ie显示
    4你的图片在客户端用遨游能够显示
    5你的图片是如果显示给用户的,是用applet还是jsp即html
    如果是html的话用<img src=图片路径>不就行了嘛,哪用那么麻烦
    6你的图片在服务端用数据库存储还是文件存储你真的要学学如何提问了,如果下次你再不说清楚我就放弃关注此贴了。
      

  6.   

    在jsp中读取图片和普通的java程序没有任何区别。但如果在jsp中使用response.getOutputStream输出流信息就要注意一下,在JSP中不能有其他的静态字符,因为在jsp中的静态字符都是使用PrintWriter对象输出的,如果这时使用getOutputStream会抛出异常,建议在Servlet中做这些事情。
      

  7.   

    1  图片是从客户端上传到服务端的
    图片上传到E://Company//WebRoot//images  文件夹下
     2 图片在客户端用遨游可以显示,但是ie不可以显示 5  图片在服务器端用文件存储 ,我的图片存储到数据库是  路径  如(img/xxx.jpg) 在显示的jsp页面中  如代码---- <img src="<%="E://Company//WebRoot//images//"+pt.getPicture() %>"
                                   
      

  8.   

    <img src=" <%="images//"+pt.getPicture() %>"
    即可
    还不行的话,在图片上面右键属性 把地址贴上来
      

  9.   

    你再上传一张只要文件在WebRoot//images//即可
    但要保证webRoot是你的应用。你的问题只是个路径问题而已。
    img是在客户端执行的,客户端哪来的E盘XX图片啊,你要明白原理才行。