css文件没有加载成功。搜了搜资料发现是因为配置了dispatchservlet后url-pattern设置为/,把静态资源都给拦截了。
解决方法:
在spring-mvc.xml中首先开启mvc的配置,然后有两种方法:
(1)<mvc:default-servlet-handler/>
(2)
-
<mvc:resources mapping="/css/**" location="/css/" />
-
<mvc:resources mapping="/js/**" location="/js/" />
-
<mvc:resources mapping="/img/**" location="/img/" />
运行后还是报错:Failed to load resource: the server responded with a status of 404 ()
检查了一下 引用的时候不该使用绝对路径。。。
改为:
<link rel="stylesheet" href="<%=request.getContextPath() %>/css/login.css" type="text/css" />