不支持的媒体类型Spring ReST资源

时间:2014-10-12 21:41:06

标签: angularjs spring rest resources

我在Rest Resource中定义了一个简单的方法,如下所示:

@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;
}

当我在页面上拨打电话时,我可以看到该网址为/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不支持的媒体类型。有人可以看看代码行,告诉我有什么问题。我非常感谢您的时间和帮助。 我在页面上调用的JS层如图所示"

 $scope.exportCase = function(studyId, caseId, exportLocation){
                 StudyService.updatecase.get({studyId:studyId,caseId:caseId}).$promise.then(function(acase){
             $scope.acase = acase;
             console.log(acase);
         });
        StudyService.exportcase.exportc({studyId: studyId,caseId:caseId,exportLocation:exportLocation},$scope.acase,
        function () {

以下的JS服务部分

exportcase : $resource('app/rest/studies/:studyId/cases/:caseId/exportlocation/:exportLocation', {}, {
        'exportc' : {
            method : 'PUT',
            params : {
                studyId : '@studyId',
                caseId : '@caseId',
                exportLocation : '@exportLocation'
            }
        },
    })

0 个答案:

没有答案