0
我有一個控制器和一個上傳文件的方法,在客戶端使用支持除IE以外的所有瀏覽器的Ajax上傳的dojo Uploader類,並上傳與IE的IFrame。 結果是一個JSON對象,但在使用的IFrame機構的情況下,JSON必須在< textarea的>括:HTTP請求結果的不同編碼取決於Accept標頭
@RequestMapping(value = "/documentation/{appId:.+}/", method = RequestMethod.POST)
@ResponseBody
public String uploadDocumentation(HttpServletRequest request,
@PathVariable String appId, @RequestParam("uploadedfile") MultipartFile file)
throws Exception {
// ....
String json = JsonUtils.jsonify(map);
if (accepts(request, "application/json")) {
return json;
} else if (accepts(request, "text/html")) {
return "<textarea>" + json + "</textarea>";
} else {
throw new GinaException("Type de retour non supporté");
}
我想知道是否有登記在框架這個編碼機制方式,所以我們只需要返回一個對象,然後讓框架完成剩下的工作。
在此先感謝。