天天看點

tomcat中jsp引用圖檔img的src屬性帶中文路徑無法顯示的解決

轉自:http://blog.csdn.net/u010509143/article/details/11720543

陳年老酒的經驗了,給忘記了。以前也處理過幾個這樣的問題。再記錄一次吧。

在html頁面中,引用了帶漢字的圖檔,形如<img src="/目錄/子目錄/圖檔名字.jpg" />,如果沒有在tomcat配置uriencoding,則無法顯示。修改方法:

在tomcat的server.xml中加入uriencoding="utf-8"(網頁的編碼是utf-8)

<connector port="8080" connectiontimeout="20000" disableuploadtimeout="true" uriencoding="utf-8" />

如果用apache代理tomcat,是通過ajp端口,是以也需要設定:

<connector port="6009" protocol="ajp/1.3" redirectport="8443" uriencoding="utf-8"/>