我正面臨以下問題其實:資源映射Spring框架3
我使用jQuery的Spring。我有控制器:
@Controller
@RequestMapping(value = "/A")
public class AController {
// not important
}
這就是處理所有host/A/...
網址罰款。但jQuery CSS樣式使用url(images/...)
,因此有host/A/index.jsp
到host/A/images/...
的引用。但我沒有這樣的文件夾,因爲/ A /只是「邏輯」URL。
我試圖
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/A/images/**" location="/images/" />
添加到我的web.xml,但現在看來,這是行不通的(第一個是工作的罰款)。例如,當我嘗試測試這個時,host/A/test.png
不起作用。
當然,我可以修改jQuery源代碼,但我不會這樣認爲。
也許我可以使用UrlRewriteFilter如果沒有簡單的解決方案。
謝謝,它對我來說工作正常 – Betlista 2012-03-21 16:14:39
只需注意其他人,有[基地標記問題IE8和IE9](http://stackoverflow.com/questions/3926197/html-base-tag-and-local-folder-path-with-internet-explorer)。 – Betlista 2012-03-22 10:22:59
@Betlista:這不是一個錯誤,因爲W3Schools鏈接說:'基地址必須是一個絕對的URL!' – sinuhepop 2012-03-22 10:31:34