首先因為在web.xml里面配置了
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
導致所有的連接都會經過DispatcherServlet,會過濾掉css、js等樣式,導致頁面無法渲染成功
因此需要在springmvc配置文件中放行靜態資源
<!--過濾靜態資源-->
<mvc:resources mapping="/common/**" location="/common/"/>
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/images/**" location="/images/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
<mvc:resources mapping="/json/**" location="/json/"/>
<mvc:resources mapping="/jsplug/**" location="/jsplug/"/>
如果配置了攔截器,在攔截器中放行靜態資源
<!--配置攔截器-->
<mvc:interceptors>
<mvc:interceptor>
<!-- 攔截所有mvc控制器 -->
<mvc:mapping path="/**"/>
<!-- mvc:exclude-mapping是另外一種攔截,它可以在你后來的測試中對某個頁面進行不攔截,這樣就不用在
LoginInterceptor的preHandler方法里面獲取不攔截的請求uri地址了(優選) -->
<!--以下資源不進行攔截-->
<mvc:exclude-mapping path="/user/toLogin" />
<mvc:exclude-mapping path="/user/login" />
<mvc:exclude-mapping path="/common/**"/>
<mvc:exclude-mapping path="/css/**"/>
<mvc:exclude-mapping path="/images/**"/>
<mvc:exclude-mapping path="/js/**"/>
<mvc:exclude-mapping path="/json/**"/>
<mvc:exclude-mapping path="/jsplug/**"/>
<bean class="com.lintrondata.fyds.interceptor.LoginInterceptor"></bean>
</mvc:interceptor>
</mvc:interceptors>
