我正在 Java 中的伺服器(NanoHTTPD)上工作,它發布圖像。然後,該圖像將被載入到 MS Word 中,其中已經有一個 Image 對象,可以透過按 F9 重新載入該對象。
它工作正常,但由於某種原因,Word 在單次刷新時加載圖像兩次。這給了我伺服器端用戶日誌中的兩個條目。當然,這是一個很小的細節,但我不喜歡以一種駭客的方式隱藏第二個日誌。
我試圖讓伺服器添加“連接:關閉”標頭,但是根據 WireShark 的說法,Word 然後只使用兩個請求而不是一個會話。
這種行為有什麼原因嗎?
編輯:
從 WireShark 可以看出:
GET / HTTP/1.1 Accept: */* User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; MASBJS; ms-office; MSOffice 16) Accept-Encoding: gzip, deflate Host: 192.168.43.1:5326 Connection: Keep-Alive HTTP/1.1 200 OK Content-Type: image/png Date: Mon, 6 Aug 2018 13:20:30 GMT Connection: keep-alive Content-Length: 79167 (transfer of PNG) GET / HTTP/1.1 Accept: */* User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; MASBJS; ms-office; MSOffice 16) Accept-Encoding: gzip, deflate Host: 192.168.43.1:5326 Connection: Keep-Alive HTTP/1.1 200 OK Content-Type: image/png Date: Mon, 6 Aug 2018 13:20:30 GMT Connection: keep-alive Content-Length: 79167 (transfer of PNG)
伺服器關閉連線後:
GET / HTTP/1.1 Accept: */* User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; MASBJS; ms-office; MSOffice 16) Accept-Encoding: gzip, deflate Host: 192.168.43.1:5326 Connection: Keep-Alive HTTP/1.1 200 OK Content-Type: image/png Date: Mon, 6 Aug 2018 15:41:06 GMT Connection: close Content-Length: 23434 (transfer of PNG) GET / HTTP/1.1 Accept: */* User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; MASBJS; ms-office; MSOffice 16) Accept-Encoding: gzip, deflate Host: 192.168.43.1:5326 Connection: Keep-Alive HTTP/1.1 200 OK Content-Type: image/png Date: Mon, 6 Aug 2018 15:41:06 GMT Connection: close Content-Length: 23434 (transfer of PNG)
答案1
也許已連接:
在“文件”>“選項”>“高級”>“常規”部分(向下滾動)中,“打開時更新自動連結”選項確實“自動更新字段和連結」。
如果我理解正確,您的圖像既是一個字段又是一個鏈接,所以也許這就是它刷新兩次的原因。嘗試取消選取此選項並按一下“確定”。