How maven projects reference css and js files

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
<

 

The so-called explosion is a violent combustion in a limited space and a limited time. It is very like life, huh, huh
 
 
Source: http://www.cnblogs.com/erpang226/p/5433096.html
 
 
 
 
 
method instead:

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
<

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325030420&siteId=291194637