我有一个FrontController,它在自制的REST框架中返回Representation。我有一些XmlRepresentation,JsonRepresentation,我现在想要一个JspRepresentation。一个UserJspRepresentation可以用来表示用户的页面或片段。那么一个JSP将是可以使用如何解析JSP页面并以String结果得到结果?
我可以做一些前瞻性/包括的东西模板,但我想的东西更加孤立,并得到结果作为对象。 forward()方法返回void。
喜欢的东西:
HttpServletRequest request = getHttpServletRequest();
User user = getUser();
request.setAttribute("user", user); // The Jsp will be aware of the user
JspRepresentation representation = new JspRepresentation(request, "userPage.jsp");
String result = representation.toString();// this is hard to get the displayed page !!!
的问题是:如何获得JSP页面作为一个String对象?
现在我只能考虑使用Java客户端,这是不是轻量级的......我也看了碧玉API中,但什么也没有发现明显的。
据我所知,JSP规范不允许在给定的JSP引擎内部,必须有一种方法来创建文档。 很显然,我将不得不放弃我JspRepresentation,因为我不想拧紧,以一种特定的技术。 –
维基百科:“JSP已被弃用遗留回落” –
当你使用JSF框架,是的。而不是当你使用纯JSP没有JSF或与如Struts,Spring MVC的,等更多细节另一个框架:http://stackoverflow.com/questions/4845032/wheres-the-official-jsp-tutorial/4847062 #4847062 – BalusC