내 문제는 내 jsp에서 mysql 데이터베이스에 중간 크기의 blob을 표시 할 수 있었다면 내 css로 이미지를 배치 할 수 없다는 것입니다.asp div에 이미지 표시
내가 원하는 것은 고정 너비와 높이를 가진 div 안에 위치시키는 것입니다.
<%@page import="java.io.OutputStream"%>
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
Statement stmnt = null;
ResultSet rs = null;
OutputStream o = null;
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost/uShare";
String username = "root";
String password = "";
PreparedStatement ps;
Blob image = null;
byte[] imgData = null;
try {
Class.forName(driver).newInstance();
Connection con = DriverManager.getConnection(url, username, password);
stmnt = con.createStatement();
rs = stmnt.executeQuery("select foto from utilizadores where idUtilizador = 13");
if (rs.next()) {
image = rs.getBlob("foto");
imgData = image.getBytes(1, (int) image.length());
out.println("encontrou imagem");
}
//mostra
response.setContentType("image/gif");
o = response.getOutputStream();
o.write(imgData);
%>
<div style="float: right; width: 20%; height: 20%;">
<%
o.flush();
%>
</div>
<%
o.close();
stmnt.close();
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
%>
</body>
</html>
고맙습니다. 100 %로
java/jsp/mysql과는 어떤 관계가 있습니까? 이는 순수한 서버 측 기술입니다. html 및 css - ** CLIENT ** 기술에 대한 도움이 필요합니다. –
당신 말이 맞아요,하지만 거기에 ASP 페이지에 이미지를 업로드하는 다른 방법이있을 것이라고 생각하고 있습니다. mySql 태그를 제거합니다 –