spring mvc对静态资源的处理

来源:互联网 发布:c语言点滴pdf百度云 编辑:程序博客网 时间:2024/06/04 17:40
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>
0 0