之前是完成了mycat的配置,现在来思考怎么把mycat与web项目结合。
公司里的大佬写了一个demo,我就负责研究好了以后用在项目里。
基本的逻辑是,页面上获取租户的信息(就是schema的名字),后台获取保存,Mybatis拦截器拦截sql语句添加前缀。
获取租户信息
前端填写信息,登录请求时放到header里。
ajax请求时,在beforeSend的函数里添加header。

现在前端数据好了,开始后端。
我们需要给请求加一个过滤器,实现HandlerInterceptor,
![]()
接口有三个方法:
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception{}
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {}
public void afterCompletion(HttpS

最低0.47元/天 解锁文章
1791

被折叠的 条评论
为什么被折叠?



