我将nodeJs应用程序分为MVC架构 模型控制器服务路由器工具日志 我的问题是我可以在服务层或控制器层中放置其余API的验证。我正在使用express 模块,并且我想使用express-validater 模块进行验证。哪一种方法更好?
当我在正文中发布数据时(x-www-form-urlencoded),在Postman中可以正常工作。但是,使用Retrofit 2.0 Android无法正常工作。
@Headers("Content-Type: application/x-www-form-urlencoded")
@POST("/api/jsonws/pushUserData")
Call<ResponseBody> pushData(@Body JSONObject jsonObj);
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("role","owner");
jsonObject.put("id","27001");
} catch (JSONException e) {
e.printStackTrace();
}
ApiInterface apiInterface1= ApiClient.getClientAuthentication().create(ApiInterface.class);
Call<ResponseBody> responseBodyCall = apiInterface1.pushData(jsonObject);
Run Code Online (Sandbox Code Playgroud)
这段代码不起作用,我也尝试@FormUrlEncoded。