extjs发送请求与controller接收请求

extjs中发送请求,参数以form表单形式上送

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link href="https://cdn.bootcss.com/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet">
      	<script src="https://cdn.bootcss.com/extjs/6.0.0/ext-all.js"></script>
      	<script>
      		Ext.onReady(function(){
				Ext.Ajax.request({
				    url: 'http://127.0.0.1:8101/user/test',
				    timeout:60000,
				    method : 'POST',//如果你没有设置这个配置项,但是存在请求参数,那么将会 使用"POST",否则将会使用"GET"。//这里测试了一下,GET\POST都是以form表单形式参数上送的
				    params: {
				    	loginName:'zhangsan',
				    	userName:'张三'
				    },
				    success: function(response){
				    	console.log("响应内容:"+Ext.decode(response.responseText));
				    	console.log("响应码:"+Ext.decode(response.responseText).code);
				    }
				});
				
			});
      	</script>
	</head>
	<body>
	</body>
</html>

controller接收请求

@Api(description = "用于测试")
@RestController
@RequestMapping(value = "/user")

public class UserController {

	@ApiOperation(value = "extjs test")
	//RequestMapping接收GET\POST请求都可以
    @RequestMapping(value = "/test")
    public Result test(HttpServletRequest httpServletRequest) {
        logger.info(httpServletRequest.getParameter("loginName"));
        User user = new User();
        user.setUserName("张三");
        user.setLoginName("zhangsan");
        return Result.res("0000","success",user);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值