1 using HttpServletResponse to handle--no need to configure the parser
@Controller Public class Ajaxcontroller { @RequestMapping ("/ajax") publicvoidthrows ioexception{ if ("SGCC". Equals (name)) { resp.getwriter (). Print ("true" ); System.out.println ("true"); } Else { resp.getwriter (). Print ("false"); }}}
Front desk
<%@ page language= "Java"Import= "java.util.*" pageencoding= "UTF-8"%><%String Path=Request.getcontextpath (); String BasePath= Request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >User name:<input type= "text" id= "Textname"/> <script type= "Text/javascript" >$ (function () {$ (' #btn '). Click (function () {$.ajax ({URL:' Ajax.do ', type:' POST ', data:{name:$ (' #textName '). Val ()}, DataType:' Text ', Success:function (data,textstatus) {alert (data); Console.log (Textstatus)}, Error:function (textstatus) {Consol E.log (Textstatus) })})</script> </body>2 SPRINGMVC processing JSON data
A import jar Package
Jackson-annotations-2.7.0.jar
Jackson-core-2.7.7.jar
Jackson-databind-2.7.8.jar
SPRINGMVC Ajax&json Treatment