jersey接收可变复杂参数使用Map接收

接收参数key:value不定,数量不定

后台代码

@Path("/add/{spallId}")
	@POST
	@Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")
	public ResultObject<RecommendTask> addTask(@PathParam("spallId") Integer spallId,
			@RequestBody Map<String, String> parameters) {

前台传参格式

<script>
		var app = angular.module('myApp', []);
			
		app.controller('siteCtrl', function($scope, $http) {
			$http({
				method: 'post',
				url: 'http://localhost:8080/rest/recommendTask/add/2',
				data:{"10":"","11":"女生"}
			}).then(function successCallback(response) {
					// 请求成功执行代码
				}, function errorCallback(response) {
					// 请求失败执行代码
			});
		  
		});
		</script



猜你喜欢

转载自blog.csdn.net/m0_37897396/article/details/78214392
今日推荐