实现Controller跳转的jsp页面中调用WEB-INF下的静态资源(js,css,img)
1.在springmvc-config.xml中配置mvc
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--mvc注解的开关-->
<mvc:annotation-driven/>
<!--配置静态资源访问-->
<mvc:resources mapping="/js/**" location="/WEB-INF/js/"/>
<mvc:resources mapping="/image/**" location="/WEB-INF/image/"/>
<mvc:resources mapping="/style/**" location="/WEB-INF/style/"/>
</beans>
2.在users.jsp中调用
<head>
<title>users</title>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/style/test.css">
<script type="text/javascript" src="${pageContext.request.contextPath }/js/test.js"></script>
</head>
<body>
<img src="${pageContext.request.contextPath }/image/1.jpg"/><br/>
<a href="${pageContext.servletContext.contextPath}/toForm" class="a">添加</a><br/>
3.框架