当使用Gson作为Retrofit Builder时,我使用:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(CustomAPI.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
Run Code Online (Sandbox Code Playgroud)
如何将JacksonConverterFactory添加到Retrofit Builder?
运用
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-jackson:1.9.0'
Run Code Online (Sandbox Code Playgroud)
作为Gradle Dependencies
在互联网上,我可以获得工厂的课程,但必须以某种方式导入,就像他们使用Gson的所有教程一样.我需要Jackson的原因是因为该公司提供的模型使用了Jackson格式化程序.
尝试处理我的创建/编辑表单我收到以下错误:
HTTP状态500 - 请求处理失败; 嵌套异常是javax.validation.UnexpectedTypeException:HV000030:找不到类型为:java.lang.Integer的验证程序.
我的控制器:
/**
* This method will provide the medium to update an existing Game.
*
* @param id bla
* @param model bla
* @return bla
*/
@RequestMapping(value = {"/edit?id={id}"}, method = RequestMethod.GET)
public String initEditGame(
@PathVariable int id,
ModelMap model
) {
Game game = gameService.findById(id);
model.addAttribute("game", game);
model.addAttribute("edit", true);
return "host/games/createOrUpdate";
}
/**
* This method will be called on form submission, handling POST request for
* updating game in database. It also …
Run Code Online (Sandbox Code Playgroud) 我在这里遇到一些问题.
Error1'System.IO.MemoryStream'不包含'CopyTo'的定义
我的代码:
// Error occurs here (CopyTo) (For Framework 4.0)
ms.CopyTo(actualAttachment);
actualAttachment.Position = 0;
//Change CopyTo to WriteTo For Framework 2.0
ms.WriteTo(actualAttachment);
actualAttachment.Position = 0;
Run Code Online (Sandbox Code Playgroud)
我不得不重新输入我的整个代码以确保所有内容都进入流中,因为我在发送文件后删除文件时遇到了一些问题.但现在我收到了这个错误.
所以基本上它现在不应该保存任何东西.
我根本没注意到我使用的是什么框架.我每天使用4种类型的框架,有时候会让我感到困惑.