maven项目引入js或css(SpringMVC):

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/J_Bang/article/details/52756411

开始时引用easyUI时一直无法引用成功报404错误,解决办法如下:

web.xml中添加下列代码(SpringMVC之前):

   <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>

jsp页面:

<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    
%>
<base href="<%=basePath%>">
<script type="text/javascript" src="<%=basePath%>static/easyui-1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>static/easyui-1.4.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=basePath%>static/easyui-1.4.1/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath%>static/easyui-1.4.1/themes/icon.css">
<link rel="stylesheet" type="text/css" href="<%=basePath%>static/easyui-1.4.1/themes/default/easyui.css">

这样就可以了

阅读更多
换一批

没有更多推荐了,返回首页