jquery .ajax demo 传参数给后台@RequestBody @RequestParms

2016-12-31 08:20:34来源:CSDN作者:fanpengfei0人点击

第七城市
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Blockchain Platform</title></head><script type="text/javascript" src="js/jquery-3.1.1.min.js"></script><script type="text/javascript">		function funcAAA(){		//alert("hellos");		// window.open("./demo.html","_parent");				console.log("request...");		$.ajax({			url:"/api/xxx/ccc",			type:"POST",			dataType:"json",			async:false,			data:{			},			success:function(data){				alert(data.code);				alert("hello");			},		});	}		    function funcBBB(){        console.log("request...");        $.ajax({            url:"/api/xxx/bbb",            type:"POST",            dataType:"json",            async:false,            data:{                "id":"id001",		"name":"name001"            },            success:function(data){                if("200"==data.code)				{				    alert(data.data);				}else{                    alert(data.code);				}            },        });    }    function funcCCC(){        console.log("request...");        $.ajax({            url:"/api/xxx/aaa",            type:"POST",            dataType:"json",            async:false,			contentType:"application/json;charset=utf-8",            data: JSON.stringify({"id":"id0003","name":"name0003"}),            success:function(message){                if("200"==message.code)                {                    alert(message.data);                }else{                    alert(message.code);                }            },			error:function(message){                $("request-process-patent").html("fail to post");			}        });    }</script><body >	<div style="text-align: center;">		<table >			<tr>				<th>uu</th>				<th><button onclick="funcAAA()">click</button></th>			</tr>			<tr>				<th>uu</th>				<th><button onclick="funcBBB()">issue</button></th>			</tr>			<tr>				<th>uu</th>				<th><button onclick="funcCCC()">issueShow</button></th>			</tr>		</table>	</div></body></html>


@RestController@RequestMapping("/api/xxx")public class AdminController{}

@RequestMapping(value="/aaa",method= RequestMethod.POST)    public JsonResult userMgr(@RequestBody Map<String,String> map){        String id=map.get("id");        String name=map.get("name");}

@RequestMapping(value="/bbb",method= RequestMethod.POST)    public JsonResult usrAdmin(@RequestParam String id, @RequestParam String name){        logger.info("assetIssue parameters:"+ id+":"+name);}




第七城市

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台