admin 管理员组文章数量: 1087139
2024年1月11日发(作者:js脚本代码生成器)
jsp发送ajax要求:
/** * 修改或者新增热门搜索 * @param hotSearch * @param request * @return */ @RequestMapping(value = "/servehotselectiveajax") @ResponseBody public int servehotselectiveajax(HttpServletRequest req,HttpServletResponse resp,@RequestBody JSONObject obj) { int count=0; int countAddHotSearch=0; int countEditHotSearch=0; ("data:"+String()); String data=String(); //解析json数据 JSONObject json = bject(data); String createArr=ing("createArr"); String modifyArr=ing("modifyArr");
if(mpty(createArr)){ JSONArray createArray=rray(createArr); for(int i=0;i<();i++){ Long tempId=bject(String((i))).getLong("tempId"); String keyword=bject(String((i))).getString("keyword"); Integer sort=bject(String((i))).getInteger("sort"); //创建热门搜索对象 HotSearch hotSearch=new HotSearch(); pid(tempId); word(keyword); t(sort); ateDate(new Date()); Flag("0"); //添加热门搜索信息 countAddHotSearch = SearchSelective(hotSearch);
} }
if(mpty(modifyArr)){ JSONArray modifyArray=rray(modifyArr); for(int i=0;i<();i++){ Long hotSearchId=bject(String((i))).getLong("id"); Long tempId=bject(String((i))).getLong("tempId"); String keyword=bject(String((i))).getString("keyword"); Integer sort=bject(String((i))).getInteger("sort"); //创建热门搜索对象 HotSearch hotSearch=new HotSearch(); SearchId(hotSearchId); pid(tempId); word(keyword); t(sort); //修改热门搜索信息 countEditHotSearch = HostSearchSelectiveById(hotSearch);
} } //判断修改或者新增成功 if(countAddHotSearch>0 || countEditHotSearch>0){ count=1; } return count; } //data:{"createArr":[{"hotSearchId":"","keyword":"ss","sort":"5","tempid":"21"}],"modifyArr":[{"hotSearchId":"205","keyword":"华为","sort":"2","tempid":"21"},{"hotSe
版权声明:本文标题:Java后台如何接收并处理前台传过来的json格式的数组参数 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1704943498a467484.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论