第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

嘗試在 golang 模板中顯示圖像

嘗試在 golang 模板中顯示圖像

Go
慕蓋茨4494581 2022-09-05 17:58:08
我使用golang來設(shè)置服務(wù)器,并在其中執(zhí)行模板。在我的模板內(nèi)部,我試圖獲得圖像,但由于某種原因,我嘗試的任何東西都不起作用。在控制臺(tái)中,它說給出該錯(cuò)誤:GET http://localhost:5051/static/photo_2021-06-17_14-18-09.jpg 404 (Not Found)圍棋代碼 :package mainimport (    "html/template"    "net/http"    // "io/ioutil")func main() {    http.HandleFunc("/a", indexHandler)    http.ListenAndServe(":5051", nil)    http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))}func indexHandler(w http.ResponseWriter, r *http.Request) {    t, _ := template.ParseFiles("templates/main.html")    t.ExecuteTemplate(w, "main", struct{}{})}模板代碼:{{ define "main" }}<html>    <head>        <meta charset="UTF-8">    </head>    <body>        <div>            <img src="../static/photo_2021-06-17_14-18-09.jpg">        </div>    </body></html>{{ end }}謝謝!
查看完整描述

1 回答

?
斯蒂芬大帝

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊

移動(dòng) http。ListenAndServe 行位于靜態(tài)處理程序下方。


查看完整回答
反對(duì) 回復(fù) 2022-09-05
  • 1 回答
  • 0 關(guān)注
  • 168 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)