我正面临以下问题其实:资源映射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