Ajax Post submission cases and SPRINGMVC annotations @requestmapping not able to get the parameter value solution

Source: Internet
Author: User

varxmlHttp; //定义变量,用来创建xmlHttp对象functionajaxfunction(url,onreadystatechangMethod,param){ // 创建xmlHttp,ajax开始    if(window.XMLHttpRequest){//非IE浏览器及IE7(7.0及以上版本),用xmlHttp对象创建        xmlHttp=new XMLHttpRequest();    }elseif(window.ActiveXObject){ //IE(6.0及以下版本)浏览器用activexobject对象创建,如果用户浏览器禁用了ActiveX,可能会失败.        xmlHttp=newActiveXObject("Microsoft.XMLHttp");    }        if(xmlHttp){//成功创建xmlHttp        param=encodeURI(param);  //URL编辑,解决乱码问题        param=encodeURI(param);        xmlHttp.open("post",url,false); //与服务端建立连接(请求方式post或get,地址,true表示异步)        xmlHttp.onreadystatechange = onreadystatechangMethod; //指定回调函数        xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");//post提交设置项        xmlHttp.send(param); //发送请求       }}

The method of @requestmapping modification in SPRINGMVC under normal circumstances, although it can be directly in the parameter list to declare parameters, but if the Ajax post method is not fetched value, so the most primitive method to get the parameters,
If there is a large amount of data in the parameter, it is best to use new string

@RequestMapping(value = "/page/video/videoReply.do")    publicString videoReply(HttpServletRequest request,            HttpServletResponse response) {  String strId = request.getParameter("strId");  String content = newString(request.getParameter("content"));    try{            content = java.net.URLDecoder.decode(content, "UTF-8");        } catch(UnsupportedEncodingException e) {            e.printStackTrace();        } returnnull;}

Ajax Post submission cases and SPRINGMVC annotations @requestmapping not able to get the parameter value solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.