标签:
环境:springmvc + ajax
前端代码:
<script type="text/javascript"> var menu = {id:1,name:"首页"}; $.getJSON("/site/menu/queryMenuPage", { menu :$.toJSON(menu), pageNum : 1, pageSize : 5 }, function(data) { alert(data); }); </script>
控制器代码:
@SuppressWarnings({ "unchecked", "rawtypes" }) @RequestMapping(value="/queryMenuPage") public @ResponseBody Page<Menu> queryMenuPage(@RequestParam Menu menu,Integer pageNum,Integer pageSize){ com.github.pagehelper.Page<Menu> _page = PageHelper.startPage(pageNum, pageSize, true); List<Menu> menuList = menuService.queryMenuList(null); try { System.err.println("pageSize:"+JsonUtil.bean2JsonStr(pageSize)); System.err.println("pageNum:"+JsonUtil.bean2JsonStr(pageNum)); System.err.println("menu:"+JsonUtil.bean2JsonStr(menu)); System.err.println("_page:"+JsonUtil.bean2JsonStr(_page)); System.err.println("menuList:"+JsonUtil.bean2JsonStr(menuList)); } catch (Exception e) { e.printStackTrace(); } return new Page(_page,menuList); }
报错:
message Failed to convert value of type ‘java.lang.String‘ to required type ‘com.join.stump.site.domain.Menu‘; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.join.stump.site.domain.Menu]: no matching editors or conversion strategy found
springmvc:Failed to convert value of type
标签:
原文地址:http://my.oschina.net/psuyun/blog/465367