$.ajax({ url:'../file/isFolderNameExist.do',//url:'${ctx}/index.jsp',cache:false,type:'post',dataType:'html',data:{ hyid:folderid,userids:foldername,contentType: "application/x-www-form-urlencoded;charset=utf-8" },success:function(html){ alert("html:"+html) } })
备注:
1 如果参数内容含中文,请添加属性contentType,这样需要做编码转换了
contentType: "application/x-www-form-urlencoded;charset=utf-8",
public void isFolderNameExist(HttpServletRequest request,HttpServletResponse response){ String folderId = request.getParameter("folderId") == null ? "" : request.getParameter("folderId"); String folodername = request.getParameter("folodername") == null ? "" : request.getParameter("folodername"); int iret = folderManager.isFolderNameExist(folderId,folodername); try { response.setCharacterEncoding("UTF-8"); PrintWriter pw = response.getWriter(); pw.write(iret); pw.flush(); pw.close(); } catch (IOException e) { e.printStackTrace(); } }原文链接:https://www.f2er.com/ajax/166518.html