为了账号安全,请及时绑定邮箱和手机立即绑定

请大神解答,我请求page 结尾的请求,他进入了json里面处理?请大神看看什么原因造成的?跪谢。

请大神解答,我请求page 结尾的请求,他进入了json里面处理?请大神看看什么原因造成的?跪谢。

qq_绿叶也有_0 2018-05-09 21:00:59
 控制层代码如下:  //取到的哪个页面     @RequestMapping("/dept.page")     public ModelAndView page(){         return  new ModelAndView("dept");     } //新增部门的方法     @RequestMapping("/save.json")     @ResponseBody     public JsonData saveDept(DeptParam param){         sysDeptService.save(param);         return JsonData.success();     }  //1     @RequestMapping("/Tree.json")     @ResponseBody     public JsonData tree(){         List<DeptLevelDto> dtoList = sysTreeService.deptTree();         return JsonData.success(dtoList);     }    请求处理拦截:如下 public class SpringExceptionResolver implements HandlerExceptionResolver {     public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object o, Exception ex) {         String url = request.getRequestURI().toString();         ModelAndView mv ;         String defaultMsg = "System error";         //这里我们要求项目中的所有请求json数据,都使用json结尾         if(url.endsWith(".json")){             if(ex instanceof SmallException || ex instanceof ParamException){                 JsonData result = JsonData.fail(ex.getMessage());                 mv = new ModelAndView("jsonView",result.toMap());             }else {                 System.out.print(ex);                 JsonData result = JsonData.fail(defaultMsg);                 mv = new ModelAndView("jsonView",result.toMap());             }             //我们要求项目中所有请求page页面,都是用.page结尾         }else if(url.endsWith(".page")){             //log.error("unknow page exception,url"+ url,ex);             JsonData result = JsonData.fail(defaultMsg);             mv = new ModelAndView("exception",result.toMap());         }else {             //log.error("unknow exception,url"+ url,ex);             JsonData result = JsonData.fail(defaultMsg);             mv = new ModelAndView("jsonView",result.toMap());         }         return mv;     } } 业务层代码:如下: @Resource private SysDeptMapper sysDeptMapper; //新增 public void save(DeptParam param){     BeanValidator.check(param);     if(checkExist(param.getParentId(),param.getName(),param.getId())){         throw new ParamException("同一层级下存在相同的部门");     }     SysDept dept = SysDept.builder().name(param.getName()).parentId(param.getParentId())             .seq(param.getSeq()).remark(param.getRemark()).build();     dept.setLevel(LevelUtil.calculatelevel(getLevel(param.getParentId()),param.getParentId()));     dept.setOperator("System");//TODO     dept.setOperateIp("127.0.0.1");//TODO     dept.setOperateTime(new Date());     sysDeptMapper.insertSelective(dept); } 错误提示:如下 url:{} , param:{}/sys/dept/dept.page{}五月 09, 2018 8:38:40  下午 org.springframework.web.servlet.PageNotFound noHandlerFound警告:  No mapping found for HTTP request with URI [/sys/dept/tree.json]   in DispatcherServlet with name 'spring'五月 09, 2018 8:38:40 下午    org.springframework.web.servlet.PageNotFound noHandlerFound警告:     No mapping found for HTTP request with URI [/favicon.ico]      in DispatcherServlet with name 'spring'url:{} ,      param:{}/sys/dept/save.json{"parentId":["0"],"id":[""],"name":["shiye"],"seq":["1"],     "remark":["gds"]}org.springframework.web.util.NestedServletException: Handler      dispatch failed; nested exception is java.lang.StackOverflowError                    以上是新增部门信息,报的错误,数据库测试链接成功
查看完整描述

1 回答

?
cxxyjsj

TA贡献119条经验 获得超22个赞

异常日志里面写的很清楚找不到tree.json,  贴出来的代码中RequestMapping是Tree.json, 大小写不一致

查看完整回答
反对 回复 2018-05-10
  • 1 回答
  • 0 关注
  • 877 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信