當前位置:首頁 » 網頁前端 » web載入圖片代碼
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

web載入圖片代碼

發布時間: 2022-04-21 03:44:06

1. web中將圖片設為背景圖片的代碼是什麼

web中將圖片設為背景圖片的代碼如下:

<html>

<body background="a.jpg">

</body>

</html>

這樣就把圖片a.jpg設為背景圖片了。

<body bgcolor="#CCCCCC">

這個是把背景設成灰色

2. java web 讀取路徑中的圖片並顯示的問題

直接用img標簽顯示啊,至於路徑是相對路徑,當然你本地上有那個圖片資源填那個絕對路徑也沒問題。

3. 怎麼在網頁中插入圖片html圖片代碼

在網頁中插入圖片html圖片代碼方法:

步驟:

一、html圖片標簽語法

<imgsrc="divcss-logo-201305.gif"width="165"height="60"/>

4. webstorm中html如何添加圖片

添加圖片是通過img標簽添加的,跟編輯器關系不大,示例如下:
<img src="圖片路徑" alt="圖片描述">
圖片的路徑可以是絕對路徑,也可以是相對路徑,alt的圖片描述是在圖片載入失敗的時候用來顯示的,也可以不寫。

5. 怎樣在WEB程序設計中插入圖片呢具體一點

在<body></body>中間插入圖片,代碼為<img
src="images/logo.gif">
一般做剛開始做網頁都有一個網頁文件和一個相關的文件夾
比如你現在的abc.htm和文件夾images
abc.htm是寫代碼用的,images就是放圖片、或者樣式、腳本文件或者其它相關的文件用的
而一般調用圖片都採用<img
src=images/051.gif">這樣的相對路徑

6. 基於myeclipse的javaweb如何添加圖片背景

myeclipse開發網頁添加背景圖片,可以使用background這個屬性,載入一張圖片,協商絕對路徑,代碼如下:
例如:bbb.jpg在image文件夾中,我們要引用bbb.jpg圖片,那麼我們引用的方式是(./image/bbb.jpg)。

css 代碼:

body
{
background-image:url(./image/bbb.jpg);
}

如果bbb.jpg在WebRoot目錄中 那我們可以直接引用:(bbb.jpg)。
css 代碼:

body
{
background-image:url(bbb.jpg);
}

7. javaweb工程如何載入圖片,越詳細越好

比如在doGet函數里載入web工程image文件夾里的一張圖片(你現在web工程里建一個),然後通過瀏覽器輸入相應的ULR即可,弄了個小DEMO,是一個servlet,如下:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//用瀏覽器查看
String path = this.getServletContext().getRealPath("/image/a.jpg");//web工程下資源的路徑
String filename = path.substring(path.lastIndexOf("//")+1);

FileInputStream in = null;
OutputStream out = null;
try{
in = new FileInputStream(path);
int len = 0;a
byte buffer[] = new byte[1024];
out = response.getOutputStream();
while((len = in.read(buffer))>0)
{
out.write(buffer, 0, len);
}

}finally{
if(in != null)
{
try{
in.close();

}catch(Exception e)
{
e.printStackTrace();
}
}
}

}

8. javaweb項目圖片載入問題

圖片都保存在資料庫裡面吧,要這樣寫:
ServletOutputStream sout = response.getOutputStream();
// jdbc 查資料庫
// selct image from imagetable where ......
sout.write(rs.getBytes(1));
sout.flush();

9. WebView怎麼載入圖片

將Html代碼通過String的形式被載入到WebView中,而且在Html中可以引用存儲在設備中的圖片資源等。這個方式可以非常方便的實現 RichTextField的效果,尤其是對某些程序提供一些本地的簡單文檔時,非常方便。
下邊是實現這個功能的源代碼:
public void loadHTML() {
final String mimeType = "text/html";
final String encoding = "utf-8";
final String html = "<h1>Header</h1><p>Custom HTML</p>
<p><img src=\"file:///android_asset/image1.jpg\" />
</p>";
WebView wv = (WebView) findViewById(R.id.wv1);
wv.loadDataWithBaseURL("fake://not/needed", html,mimeType, encoding, "");
}

10. java web開發,上傳圖片並讀取

java web開發中,使用文件操作類來上傳圖片並讀取,如下代碼:

*@desc:圖片處理工具
*@author:bingye
*@createTime:2015-3-17下午04:25:32
*@version:v1.0
*/
publicclassImageUtil{

/**
*將圖片寫到客戶端
*@author:bingye
*@createTime:2015-3-17下午04:36:04
*@history:
*@paramimage
*@paramresponsevoid
*/
publicstaticvoidwriteImage(byte[]image,HttpServletResponseresponse){
if(image==null){
return;
}
byte[]buffer=newbyte[1024];
InputStreamis=null;
OutputStreamos=null;
try{
is=newByteArrayInputStream(image);
os=response.getOutputStream();
while(is.read(buffer)!=-1){
os.write(buffer);
os.flush();
}
}catch(IOExceptione){
e.printStackTrace();
}finally{
try{
if(is!=null){is.close();}
if(os!=null){os.close();}
}catch(IOExceptione){
e.printStackTrace();
}
}
}

/**
*獲取指定路勁圖片
*@author:bingye
*@createTime:2015-3-21上午10:50:44
*@paramfilePath
*@paramresponsevoid
*/
publicstaticvoidwriteImage(StringfilePath,HttpServletResponseresponse){
FileimageFile=newFile(filePath);
if(imageFile!=null&&imageFile.exists()){
byte[]buffer=newbyte[1024];
InputStreamis=null;
OutputStreamos=null;
try{
is=newFileInputStream(imageFile);
os=response.getOutputStream();
while(is.read(buffer)!=-1){
os.write(buffer);
os.flush();
}
}catch(FileNotFoundExceptione){
e.printStackTrace();
}catch(IOExceptione){
e.printStackTrace();
}finally{
try{
if(is!=null){is.close();}
if(os!=null){os.close();}
}catch(IOExceptione){
e.printStackTrace();
}
}
}
}

/**
*圖片上傳到文件夾
*@author:bingye
*@createTime:2015-3-20下午08:07:25
*@paramfile
*@paramsavePath
*@returnboolean
*/
(CommonsMultipartFilefile,StringsavePath){
if(file!=null&&!file.isEmpty()){
//獲取文件名稱
StringfileName=file.getOriginalFilename();
//獲取後綴名
StringsuffixName=fileName.substring(fileName.indexOf(".")+1);
//新名稱
StringnewFileName=System.currentTimeMillis()+"."+suffixName;
//新文件路勁
StringfilePath=savePath+newFileName;
//獲取存儲文件路徑
FilefileDir=newFile(savePath);
if(!fileDir.exists()){
//如果文件夾沒有:新建
fileDir.mkdirs();
}
FileOutputStreamfos=null;
try{
fos=newFileOutputStream(filePath);
fos.write(file.getBytes());
fos.flush();
returnResultUtil.success("UPLOAD_SUCCESS",URLEncoder.encode(newFileName,"utf-8"));
}catch(Exceptione){
e.printStackTrace();
returnResultUtil.fail("UPLOAD_ERROR");
}finally{
try{
if(fos!=null){
fos.close();
}
}catch(IOExceptione){
e.printStackTrace();
returnResultUtil.fail("UPLOAD_ERROR");
}
}
}
returnResultUtil.fail("UPLOAD_ERROR");
}}