在Oracle数据库中显示图像数据时在JSP中显示图像
我试图从oracle数据库访问图像数据,并在jsp上显示图像。编写以下代码。在Oracle数据库中显示图像数据时在JSP中显示图像,jsp,Jsp,我试图从oracle数据库访问图像数据,并在jsp上显示图像。编写以下代码。 使用chrome浏览器时,会出现图像数据未转换为图像格式的错误。如何为每个浏览器解决此问题。您以前在本页的何处调用过getWriter()吗? 从文档中: 可以调用此方法或getWriter()来编写主体,而不是同时调用两者 希望这能有所帮助 如果字符串作为图像名称存储在oracle数据库中,我建议使用字符串 在显示时,我们需要将字符串附加到位置 <% try { ResultSet rs=stmt.
使用chrome浏览器时,会出现图像数据未转换为图像格式的错误。如何为每个浏览器解决此问题。您以前在本页的何处调用过getWriter()吗?
从文档中:
可以调用此方法或getWriter()来编写主体,而不是同时调用两者
希望这能有所帮助
如果字符串作为图像名称存储在oracle数据库中,我建议使用字符串
在显示时,我们需要将字符串附加到位置
<%
try
{
ResultSet rs=stmt.executeQuery("select * from PICTABLE where ID=200");
if(rs.next())
{
String b1=rs.getString("PIC");
byte x[]=b1.getBytes(1, (int)b1.length());
OutputStream o=response.getOutputStream();
o.write(x);
o.close();
}
System.out.println("Done");
}
catch(Exception ex)
{
ex.printStackTrace();
}
%>
<img src="foldername/<%=b1%>" style="height:200px;"/>
“style=”高度:200px;"/>
[java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause
java.lang.IllegalStateException: getOutputStream() has already been called for this response
<%
try
{
ResultSet rs=stmt.executeQuery("select * from PICTABLE where ID=200");
if(rs.next())
{
String b1=rs.getString("PIC");
byte x[]=b1.getBytes(1, (int)b1.length());
OutputStream o=response.getOutputStream();
o.write(x);
o.close();
}
System.out.println("Done");
}
catch(Exception ex)
{
ex.printStackTrace();
}
%>
<img src="foldername/<%=b1%>" style="height:200px;"/>