Визуализация нескольких представлений в одном запросе

Я пытаюсь вернуть несколько представлений в одном запросе, возвращая их все в строке JSON.

Пример:

@RequestMapping(value = "my-request")
public void myRequest(HttpServletRequest request, HttpServletResponse response) throws Exception
{
    Map model1 = new Hashtable();
    model1.put(...);
    ModelAndView modelAndView1 = new ModelAndView("path/to/view1", model1);
    // Render modelAndView1 in some way, in order to obtain the rendered HTML as a String

    Map model2 = new Hashtable();
    model2.put(...);
    ModelAndView modelAndView2 = new ModelAndView("path/to/view2", model2);
    // Render modelAndView2 in some way, in order to obtain the rendered HTML as a String

    // Now write a JSON String to the HttpServletResponse containing both the rendered views (strings).
    // (this is not part of my problem, I'm able to do it as long as I have the two strings)
}

Я использую Spring MVC с плитками 2.

Кто-нибудь может мне помочь?

Обновление 1- Имена представлений разрешаются с помощью ViewResolver:


    
    

Обновление 2- Я создал репозиторий github, содержащий очень небольшой пример, воспроизводящий проблему.

5
задан satoshi 29 April 2012 в 15:15
поделиться