您的位置:首页 > 编程语言 > Java开发

spring mvc对静态资源的处理

2016-08-10 14:58 232 查看
1.web.xml中拦截的url设置为/来让sping mvc 处理

2.Restful风格(@PathVariable("参数"))

3.对静态资源的处理

在spring-mvc.xml中添加
<mvc:annotation-driven/>

<mvc:resources mapping="/resources/**" location="/images/"/>

<mvc:resources mapping="/resources2/**" location="/css/"/>

4.如要使用images下的图片在jsp页面中可以:
    <img alt="文章列表" src="${pageContext.request.contextPath}/resources/article_list.jpg">

如果使用css样式
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources2/css.css"/>
</head>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: