【发布时间】:2016-03-21 01:43:04
【问题描述】:
试图了解发送值的 Hashmap 有什么问题。
客户端(角度)
var params = {
year: reportYear,
reportAgg: {
"interest": "Java",
"domain": "JavaCodeGeeks.com"
}
};
return $http.post('test/' + pathVariable1 + '/',
$.param(params), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
服务器端(Spring/Jackson)
@RequestMapping(value = RqMapping, method = RequestMethod.POST)
public ResponseEntity sendReports(
final @PathVariable(value = "pathVariable1") String organizationId,
final @RequestParam(value = "year", required = true) int requestedYear,
final @RequestParam(value = "reportAgg", required = false) Map<String, String> reportAgg,
final HttpServletRequest request) {
在request.getParametersMap 中可以看到预期的reportAgg[interest] 和reportAgg[domain],但我仍然在映射中得到reportAgg 的空值。
【问题讨论】:
-
stackoverflow.com/questions/17765234/… - 我试着把它当作这个 SO 问题。
-
您的 http 请求看起来如何?你有例子吗?
标签: java angularjs spring spring-mvc jackson