GVKun编程网logo

如何从mysql db检索图像并将其显示在内部并用HTML标记?

15

在本文中,您将会了解到关于如何从mysqldb检索图像并将其显示在内部并用HTML标记?的新资讯,并给出一些关于android–如何从模拟器的SD卡中获取所有图片并将其显示在listView中?、Ex

在本文中,您将会了解到关于如何从mysql db检索图像并将其显示在内部并用HTML标记?的新资讯,并给出一些关于android – 如何从模拟器的SD卡中获取所有图片并将其显示在listView中?、Excel 2007:如何从列表中提取所有可能的2对组合并将其显示在2个单独的列中、Flutter:如何解析HTML属性中的“标题”数据并将其显示在ListView中?、html – 如何将png二进制数据放入img标签并将其显示为图像?的实用技巧。

本文目录一览:

如何从mysql db检索图像并将其显示在内部并用HTML标记?

如何从mysql db检索图像并将其显示在内部并用HTML标记?

如何从mysql db检索图像并将其显示在HTML的标记内,并且应将img标记置于其中?这是我的代码:它仅显示图像。除了图像以外,没有显示任何其他内容。

提前致谢。

 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"      "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body><%@ page import="java.io.*"%><%@ page import="java.sql.*"%><%@ page import="java.util.*"%><%@ page import="java.text.*"%><%@ page import="javax.servlet.*"%><%@ page import="javax.servlet.http.*"%><%@ page import="javax.servlet.http.HttpSession"%><%@ page language="java"%><%@ page session="true"%><%  try{   //PrintWriter out=response.getWriter();  out.println("Retrieve Image Example!");  String driverName = "com.mysql.jdbc.Driver";  String url = "jdbc:mysql://localhost:3306/";  String dbName = "db";  String userName = "root";  String password = "root";  Connection con = null;  Class.forName(driverName);  con = DriverManager.getConnection(url+dbName,userName,password);  Statement st = con.createStatement(); %>  <table border=''1''> <tr> <td>Name:</td><td> </td>My Name</td> </tr> <tr> <td>Image:</td> <td width=10px;> <% PreparedStatement pre1 = con.prepareStatement("select * from image where id="+8); ResultSet rs1=pre1.executeQuery(); while(rs1.next())    {byte[] bytearray1 = new byte[4096];                int size1=0;               InputStream sImage1;                 sImage1 = rs1.getBinaryStream(2);                 response.reset();                response.setContentType("image/jpeg");                response.addHeader("Content-Disposition","filename=logo.jpg");                while((size1=sImage1.read(bytearray1))!= -1 )                  {                    response.getOutputStream().write(bytearray1,0,size1);                  }                response.flushBuffer();               sImage1.close();                rs1.close();             }    out.println("Retrieved Successfully!");  pre.close();  con.close();    }  catch (Exception e){  out.println(e.getMessage());  }%></td></tr> </table></body>  </html>

答案1

小编典典

图像作为单独的请求加载到加载html的请求中。因此,您需要:

  • 建立你指定的时候使用URL编码方案src中的img元素。
  • 将一个servlet(或类似名称)映射到该URL。Servlet根据URL的参数加载图像,并在响应中返回该图像。

android – 如何从模拟器的SD卡中获取所有图片并将其显示在listView中?

android – 如何从模拟器的SD卡中获取所有图片并将其显示在listView中?

我的模拟器的SD卡中有一个名为images的文件夹.此文件夹包含从我的应用程序中单击的图片.我想将该文件夹中的所有图片显示到列表视图中.我怎样才能做到这一点?提前致谢.

解决方法

这应该让你开始.

http://android-er.blogspot.com/2010/01/android-file-explorer-with-jpgs-exif_08.html

计算要求的简单逻辑,

private void getDir(String dirPath)
{
myPath.setText("Location: " + dirPath);

item = new ArrayList<String>();
path = new ArrayList<String>();

File f = new File(dirPath);
File[] files = f.listFiles();

if(!dirPath.equals(root))
{

 item.add(root);
 path.add(root);

 item.add("../");
 path.add(f.getParent());

}

for(int i=0; i < files.length; i++)
{
  File file = files[i];
  path.add(file.getPath());
  if(file.isDirectory())
   item.add(file.getName() + "/");
  else
   item.add(file.getName());
}

ArrayAdapter<String> fileList =
 new ArrayAdapter<String>(this,R.layout.row,item);
setlistadapter(fileList);
 }

Excel 2007:如何从列表中提取所有可能的2对组合并将其显示在2个单独的列中

Excel 2007:如何从列表中提取所有可能的2对组合并将其显示在2个单独的列中

如何解决Excel 2007:如何从列表中提取所有可能的2对组合并将其显示在2个单独的列中?

我遇到以下问题:我有x,y和z值来描述多个对象的位置。每个值都写在其单独的单元格中。

These are my data

ID     X,Center of (object)    Y,Center of (object)   Z,Center of (object)
206    497.216                  1221.0065               142.086
210    397.8002                 1226.8419               142.0019
213    432.8625                 1227.1501               223.5755
216    413.0157                 1244.3332               138.5435
217    461.5609                 1108.214                78.106
218    464.9693                 1250.1958               140.4711

我要为所有可能的组合计算2个对象之间的距离。通常,我都是通过手工创建组合来做到这一点的,因此最终我的数据如下所示:

This is how the newly arranged data should look like,with all combinations but no duplicates

有什么方法可以自动执行此操作?将所有对象组合从一个列表中彼此相邻,而每个值都保留在自己的单元格中,以便我仍然可以进行计算? 任何帮助都非常感谢!我真的很疯狂,用手做安排...:/

ID1   X         Y           Z           ID2    X            Y           Z
206   497.216   1221.0065   142.086     210    397.8002 1226.8419   142.0019
206   497.216   1221.0065   142.086     213    432.8625 1227.1501   223.5755 

对于数据列表中的所有项目(ID),我希望能够计算该ID与另一个ID的距离。

例如,对于ID 206,我想创建组合(计算),以便计算ID 210,213,216,217,然后对ID 210等进行计算。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

Flutter:如何解析HTML属性中的“标题”数据并将其显示在ListView中?

Flutter:如何解析HTML属性中的“标题”数据并将其显示在ListView中?

您可以在解析html之前提取title。 假设response.data返回<td>....</td> html的列表。您必须遍历每个<td>...</td>并提取标题。

例如, 假设您获得如下列表:

"data": [
    "<td>...</td>","<td>...</td>",...
    "<td>...</td>",]

只需遍历每个元素并使用下面的getTitle方法提取标题即可。

String getTitle(String html) {
  // html = '''<td> <a href="javascript:void(0);"onclick="fnView('BBSMSTR_000000012758','19151090'); " title="title 1">
  //          title 1</a>'''
  if(html.contains('title=')) {
    html = html.substring(html.indexOf('title='));
    html = html.substring(6,html.indexOf('>'));
    html = html.replaceAll('"','');
    print(html); // Prints title 1
  }
  return html;
}

html – 如何将png二进制数据放入img标签并将其显示为图像?

html – 如何将png二进制数据放入img标签并将其显示为图像?

我正在使用这个
$.ajax({
            type: "GET",url: 'template/bump1/purse.png',datatype:"image/png",success: function (data) {


                var reader = new FileReader();

                reader.onload = function (e) {
                  var img = document.getElementById("Captchaimg");
                  img.src = e.target.result;
                };
                reader.readAsDataURL(data);


                //$('#Captchaimg').attr('src',data);
            }
         });

下载图像,它以二进制形式出现,看起来像这样

node.js将其返回为

WriteHeaderMode('image/png',res,200);
                        res.end(data,'binary');

但现在,我如何将其放入图像标记并将其显示为图像.注意:我不想将返回数据作为base64编码,它必须是二进制的.我很好,在客户端将二进制文件转换为base64.

当我将它传递给readAsDataURL时,它会显示TypeError异常.

谢谢

编辑

var img = document.getElementById("Captchaimg");

                  var reader = new FileReader();

                  reader.onload = function(e) {
                      //img.src = e.target.result;
                      $("body").html(e.target.result);
                    };

                  reader.readAsDataURL(new Blob([data]));

这似乎将它转换为base64编码,它以data:application / octet-stream; base64开头,但不显示图像…

解决方法

jQuery Ajax不支持二进制响应( okay now it does),有一个技巧使用overrideMimeType(‘text / plain; charset = x-user-defined’)将每个字节作为响应字符串中的字符返回,然后循环遍历响应创建数据的字节数组.

但是使用裸露的XMLHttpRequest,可以使用responseType属性轻松完成.

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
    if (this.readyState == 4 && this.status == 200){
        var img = document.getElementById("Captchaimg");
        var url = window.URL || window.webkitURL;
        img.src = url.createObjectURL(this.response);
    }
}
xhr.open('GET','template/bump1/purse.png');
xhr.responseType = 'blob';
xhr.send();

今天关于如何从mysql db检索图像并将其显示在内部并用HTML标记?的分享就到这里,希望大家有所收获,若想了解更多关于android – 如何从模拟器的SD卡中获取所有图片并将其显示在listView中?、Excel 2007:如何从列表中提取所有可能的2对组合并将其显示在2个单独的列中、Flutter:如何解析HTML属性中的“标题”数据并将其显示在ListView中?、html – 如何将png二进制数据放入img标签并将其显示为图像?等相关知识,可以在本站进行查询。

本文标签: