【发布时间】:2012-11-28 16:25:48
【问题描述】:
我是 spring 新手,正在尝试。
我有一个 jsp 文件,其中包含如下 css 和图像
<link href="css/style.css" rel="stylesheet" type="text/css" />
现在我有一个 url 路径为 /localhost/myapp/test/tst,它被映射到一个控制器,然后将它转发到查看 jsp
view.jsp 存在
/web-inf/jsp/view.jsp
但是当点击路径 /localhost/myapp/test/tst 时,css 和图像路径被解析为
/localhost/myapp/test/tst/css/style.css
实际上我希望它以/localhost/myapp/css/style.css 的形式出现
css 和 html 存在于 webapp 的根目录中
我如何在我的 spring 配置中关注
<mvc:annotation-driven />
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/css/**" location="/css/" />
【问题讨论】:
-
你为什么不用
<link href="/css/style.css"?
标签: java spring spring-mvc