美文网首页
Spring MVC 中的@Scope("protot

Spring MVC 中的@Scope("protot

作者: ettingshausen | 来源:发表于2016-10-31 18:36 被阅读143次

最近项目中使用Mybaits分页查询经常偶发错误,问题如下:

select top ${pageSize} from a

其中${pageSize}这个经常丢失,导致查询语句错误。

最近突然发现,两个ajax,有时候后面的ajax会吧前一个ajax在Controller里的的request修改掉,问题就出现在这里。

原因在于两个ajax的@RequestMapping value是一样的,params不同,后面的ajax对应的action复用了前一个action。如果@RequestMappingvalue不一样,则不会有问题。

解决办法是在Action上面注解@Scope("prototype")

@Controller
@Scope("prototype")
public class ManagementControl extends BaseController {

}

相关文章

网友评论

      本文标题:Spring MVC 中的@Scope("protot

      本文链接:https://www.haomeiwen.com/subject/nilfuttx.html