jsp加入图片流后显示不了其他内容怎么办

AnnJune 2017-12-24 03:19:50

<%
out.clear();
out=pageContext.pushBody();
response.sendRedirect("photo.jsp");
%>
</div>
<div id="section">
<%--<jsp:include page="photo.jsp"/>--%>
<img style="width: 50%;height: 50%" src="photo.jsp"/>1234
</div>


photo.jsp代码

<%
//数据库用户名
String userName = "root";
//密码
String userPasswd = "nxycmjh19960622";
//数据库名
String dbName = "student";
//联结字符串
String url = "jdbc:mysql://localhost:3306/student";
Connection photoConn;
ResultSet photoRs=null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
photoConn=DriverManager.getConnection(url,userName,userPasswd);
Statement photoStatement=photoConn.createStatement();
photoRs=photoStatement.executeQuery("select photos1 from photos where studentId='201430001'");
if(photoRs.next()){
Blob blob=photoRs.getBlob("photos1");
int size=(int)blob.length();
out.print(size);
InputStream inputStream=blob.getBinaryStream();
byte[] bytes=new byte[size];
response.setContentType("image/jpeg");
ServletOutputStream servletOutputStream=response.getOutputStream();
int bytesRead=0;
while((bytesRead=inputStream.read(bytes))!=-1){
servletOutputStream.write(bytes,0,bytesRead);
}
inputStream.close();
servletOutputStream.flush();
servletOutputStream.close();
out.clear();
}
%>


加了图片以后显示不了其他内容,也不能控制图片大小,求大神帮忙解答一下
...全文
166 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hlyzchenyanyu 2017-12-25
  • 打赏
  • 举报
回复
response.sendRedirect("photo.jsp");//重定向,页面跳转了 在页面内显示图片 <img style="width: 50%;height: 50%" src="photo.jsp"/>这样写就可以了
什么都不能 2017-12-24
  • 打赏
  • 举报
回复
out.clear(); out=pageContext.pushBody(); response.sendRedirect("photo.jsp"); 本身也没啥内容啊

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧