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é");
}
我想知道是否有登记在框架这个编码机制方式,所以我们只需要返回一个对象,然后让框架完成剩下的工作。
在此先感谢。