有个删除页面,删除完成后用SpringMVC redirect到列表页面,代码如下:
@RequestMapping(value ="/{id}/delete",method = RequestMethod.GET) public String delete(@PathVariable String id,HttpServletRequest request) { userService.deleteById(id); return "redirect:/user/list"; }
配置有一个全局的拦截器
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if (null == modelAndView) { return; } // 系统配置参数 String basePath = HttpUtils.getBasePath(request); String contextPath = HttpUtils.getContextPath(request); modelAndView.addObject("basePath", basePath); modelAndView.addObject("contextPath", contextPath); }
现在的问题是,redirect后的地址栏总是将modelAndView中的参数拼接上了,如下:
http://localhost:8080/macaque/user/list?basePath=http%3A%2F%2Flocalhost%3A8080%2Fmacaque&ssss=%2Fmacaque&contextPath=%2Fmacaque
但是如果用response.sendRedirect("")的话 地址栏正常如下:
http://localhost:8080/macaque/user/list
求助 这是什么原因呢,怎么解决