Angularjs 不支持的媒体类型Spring ReST资源
我在我的Rest资源中定义了一个简单的方法,如下所示:Angularjs 不支持的媒体类型Spring ReST资源,angularjs,spring,rest,resources,Angularjs,Spring,Rest,Resources,我在我的Rest资源中定义了一个简单的方法,如下所示: @RequestMapping(value = "/{studyId}/cases/{caseId}/exportlocation/{exportLocation}", method = RequestMethod.PUT) @Timed public void exportCase(@PathVariable Long studyId, @PathVariable Long caseId, @PathVariable String exp
@RequestMapping(value = "/{studyId}/cases/{caseId}/exportlocation/{exportLocation}", method = RequestMethod.PUT)
@Timed
public void exportCase(@PathVariable Long studyId, @PathVariable Long caseId, @PathVariable String exportLocation,
@RequestBody Case acase) throws Exception {
log.debug("REST request to export Case {} for Study : {}", acase, studyId);
String exportFileName = exportService.exportCase(acase, "test");
// if (exportFileName == null) {
// response.sendError(HttpServletResponse.SC_NOT_FOUND, "Can't Export");
// }
// return exportFileName;
}
当我在页面上打电话时,我可以看到URL为/app/rest/studies/1/cases/1/exportlocation/test
我将请求映射定义为
@RequestMapping(value = StudyResource.REQUEST_MAPPING, produces = MediaType.APPLICATION_JSON_VALUE)
@Secured(AuthoritiesConstants.USER)
public class StudyResource {
private final Logger log = LoggerFactory.getLogger(StudyResource.class);
public static final String REQUEST_MAPPING = "/app/rest/studies";
但继续获取415不支持的媒体类型。有人能看一下代码行,告诉我出了什么问题吗。我非常感谢你的时间和帮助。
页面上调用的My JS层如图所示“
下面是JS服务部分
exportcase : $resource('app/rest/studies/:studyId/cases/:caseId/exportlocation/:exportLocation', {}, {
'exportc' : {
method : 'PUT',
params : {
studyId : '@studyId',
caseId : '@caseId',
exportLocation : '@exportLocation'
}
},
})
你如何调用相关的URL?你能给我们看一下那段代码吗?[[Angular JS Service]]exportcase:$resource('app/rest/studies/:studyId/cases/:caseId/exportlocation/:exportlocation',{},{'exportc':{method:'POST',params:{studyId:'@studyId',caseId:'@caseId',exportLocation:'@exportLocation'},},[[Angle Controller Call]]$scope.exportCase=函数(studyId,caseId,exportLocation){StudyService.exportCase.exportc({studyId:studyId,caseId:caseId,exportLocation:exportLocation},$scope.acase,function(){您需要将它添加到问题中,因为它很重要。只做了,但没有回答
exportcase : $resource('app/rest/studies/:studyId/cases/:caseId/exportlocation/:exportLocation', {}, {
'exportc' : {
method : 'PUT',
params : {
studyId : '@studyId',
caseId : '@caseId',
exportLocation : '@exportLocation'
}
},
})