HTML
<img alt="点击设定" name="CONSTRUCTIONPLANHIS_IMAGE_curr_img_0" src="view/showImage/${image}">
JAVA
import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import com.ajz.util.FileUtil; @Controller @RequestMapping(value = "/view") public class ImageViewController { @RequestMapping("showImage/{pic_name:.+}") public void showImage(HttpServletResponse response, @PathVariable String pic_name) {// pic_addr:图片路径(d:\\upload\a.jpg) response.setContentType("image/*"); FileInputStream fis = null; OutputStream os = null; try { fis = new FileInputStream(FileUtil.getRealPath() + pic_name); os = response.getOutputStream(); int count = 0; byte[] buffer = new byte[1024 * 8]; while ((count = fis.read(buffer)) != -1) { os.write(buffer, 0, count); os.flush(); } } catch (Exception e) { e.printStackTrace(); } finally { try { fis.close(); os.close(); } catch (IOException e) { e.printStackTrace(); } } } }