提交表单后台如何返回json?前台没有弹出提示框,而是返回了一个空白页面
< 返回列表时间: 2016-06-03来源:开源中国
HDC调试需求开发(15万预算),能者速来!>>>
希望点击保存按钮后,后台进行添加操作,添加成功后提示添加成功。
jsp页面

<div class="pageContent"> <form method="post" action="/SmartNetRoot/product/addProduct" class="pageForm required-validate" onsubmit="return validateCallback(this);"> <div class="pageFormContent" layoutH="56"> <p> <label>产品名称:</label> <input name="newProductName" type="text" size="30" class="required"/> </div> <div class="formBar"> <ul> <!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>--> <li><div class="buttonActive"><div class="buttonContent"><button type="submit" >保存</button></div></div></li> <li> <div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div> </li> </ul> </div> </form> </div>






后台controller

@RequestMapping("/addProduct") public ModelAndView addProduct(HttpServletRequest request, HttpServletResponse response) throws IOException { String newProductName = request.getParameter("newProductName"); System.out.println("新产品添加成功!"); System.out.println(newProductName); JSONObject dwzServerJson = new JSONObject(); dwzServerJson.put("statusCode", "200"); dwzServerJson.put("message", "111"); dwzServerJson.put("navTabId", "productView"); dwzServerJson.put("rel", ""); dwzServerJson.put("callbackType", "closeCurrent"); dwzServerJson.put("forwardUrl", ""); request.setAttribute("json", dwzServerJson); return null; }





热门排行