UserControler:
@RequestMapping(value="index")
public String index(){return "index";
}
写完代码之后页面可以正常跳转,但是页面内容出现错乱。
分析原因:
引用了静态资源,可能是css文件引用不成功。
最终的解决方案:
在dispatcher-servlet中引用了静态资源。
如果能跳转,但是页面内容出现错乱,可以看看是否在dispatcher-servlet中引用了静态资源。
如何引用了静态资源要配置:
本项目要使用的引用:
<!-- 对静态资源的引用 -->
<mvc:resources mapping="/bank_img/**" location="/bank_img/"
cache-period="31556926" />
<mvc:resources mapping="/images/**" location="/images/"
cache-period="31556926" />
<mvc:resources mapping="/image/**" location="/image/"
cache-period="31556926" />
<mvc:resources mapping="/js/**" location="/js/"
cache-period="31556926" />
<mvc:resources mapping="/css/**" location="/css/"
cache-period="31556926" />
<mvc:resources mapping="/products/**" location="/products/"
cache-period="31556926" />