私はSparkファミリのWebアプリケーションを開発しています。いずれかのサイトでは、動的コンテンツの読み込みを有効にします。SparkJavaウェブサイトの動的更新
// this is called by get("/module", (req, resp)-> ...);
public static ModelAndView getModules(Request req, Response res) {
Map<String, Object> model = new HashMap<String, Object>();
List<Module> modules = new ArrayList<>();
model.put("modules", modules);
lookForModules(this);
return new ModelAndView(model, "pathToSiteSource");
}
private lookForModules(Listener listener){
// modules search in the background thread
// when any module is found I inform the listener;
// different modules can be found in various times
}
public void onModulesFound(List<Module> modules){
// I want to update the site using the modules that I got
}
私はWebSocketをを移動するための方法ですが、例という読み:私はそれで意味は、Javaコントローラに例えば、私は、サーバーでいくつかの情報を検索し、検索が終了したときに、私はウェブサイトを更新したいということですWebSockets on SparkウェブサイトはAJAX呼び出しを使用しており、私の検索はJavaクラスで行われなければなりません。とにかくこれを行う正しい方法はWebSocketですか?