私はこの場合、ModelAndView(実際は可能です)を渡すことはできません。しかし、最良の選択肢はRESTを使うことです。このメソッドをREST APIメソッドにすることができます。 Jasonオブジェクトを渡します。一般的に
、Webアプリケーションは、第三部のアプリケーションが使用するREST APIを介してそのサービスを公開したり、モバイルアプリケーション
@RestController
public class CityController {
@Autowire
private WhatsNewService whatsNewService;
@RequestMapping(method = RequestMethod.GET, value = "/city/{cityId}")
public City showCity(@PathVariable("cityId") int cityId){
return this.whatsNewService.findCityById(cityId);
}
}
それとも、同じ@Controller
クラスを使用して
@Controller
public class CityController {
@Autowire
private WhatsNewService whatsNewService;
@RequestMapping(method = RequestMethod.GET, value = "/city/{cityId}")
public @ResponseBody City showCity(@PathVariable("cityId") int cityId){
return this.whatsNewService.findCityById(cityId);
}
}
可能に電力を供給します
アンドロイドクライアント側では、ライブラリのようなRETROFITを使用して、josnオブジェクトをアプリケーションオブジェクトにマップできます。
改善されたスペルと文法 –