こんにちは、私は現在、id で指定された特定のポイントでコンテンツを特定のページに挿入する必要がある春 (3.2.x) アプリケーションを開発しています。
これは私が現在行っていることです:
@RequestMapping(value = "/{part}", method = RequestMethod.POST, produces="text/html")
@ResponseBody
public String enterModul(HttpServletRequest request, @PathVariable String part, @ModelAttribute Body body){
//body handling omitted
//getting the external html
String frame = restTemplate.getForObject("...externalUrl", String.class);
//getting my content
String uri = request.getRequestURL().toString();
String content = restTemplate.getForObject(uri, String.class);
// merge frame and content
String completeView = this.mergeFrameAndContent(frame, content);
return completeView;
}
@RequestMapping(value = "/{part}", method = RequestMethod.GET, produces="text/html")
@ResponseBody
public ModelAndView getInitialContentForPart(@PathVariable String part) {
//irrelevant code/model creation ommited
//just using InternalResourceViewResolver so nothing fancy here
ModelAndView view = new ModelAndView(part, "model", model);
return view;
}
private String mergeFrameAndContent(String frame, String content) {
//id identifies position
String view = frame.replace("id", content);
return view;
}
しかし、このようにすることは、どういうわけか正しく感じられません。より良い解決策はありますか?タイル3でやってみましたがうまくいきませんでした。