The project directory structure is as follows:
Purpose :
Reference hello.js and base.css files in index.jsp
Implement :
In web.xml, add
<servlet-mapping>
<servlet-name >default </servlet-name >
<url-pattern >*.js</url-pattern>
</servlet-mapping >
<servlet-mapping >
<servlet-name >default </servlet-name >
<url-pattern >*.css</url-pattern>
</servlet-mapping >
These two pieces of code are written before the introduction of springMVC code.
jsp page, write
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + " /";
%>
this java code, then use
<
Configure in the spring-mvc.xml file:
<!-- Enable annotation support-->
<mvc:annotation-driven />
<!-- 静态资源 -->
<mvc:resources location="/WEB-INF/js/" mapping="/js/**"/>
<mvc:resources location="/WEB-INF/css/" mapping="/css/**"/>
<mvc:resources location="/WEB-INF/image/" mapping="/image/**"/>
Purpose :
Reference hello.js and base.css files in index.jsp
Implement :
In web.xml, add
<servlet-mapping>
<servlet-name >default </servlet-name >
<url-pattern >*.js</url-pattern>
</servlet-mapping >
<servlet-mapping >
<servlet-name >default </servlet-name >
<url-pattern >*.css</url-pattern>
</servlet-mapping >
These two pieces of code are written before the introduction of springMVC code.
jsp page, write
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + " /";
%>
this java code, then use
<