背景:java
视图解析器(咱们用的是velocity) spring
报错:session
because of an existing model object of the same nameide
按照网上给的缘由 :blog
设置了属性exposeSessionAttributes为true以后,全部的session中的变量都会在传给视图(velocity模板)时被合并到model中。这时若是在控制器中使用了@sessionAttributes注解(会把session中指定的变量存到model中),在最后合并model的时候会报Cannot expose session attribute 'xxx' because of an existing model object of the same name异常。查看了AbstractTemplateView.java文件后,发现spring在合并的时候还判断了allowSessionOverride这个属性,若是为false,就会抛出上面提到的异常。因此这种状况下,还要在配置文件的viewResolver中添加allowSessionOverride属性,value为true,这样即便遇到重复的值,也会直接使用Map中的put方法将旧值覆盖。ci
发现并不行 ,最后源代码断点看了下it
OK 那么久是须要配置下这个判断条件io
解决了模板