OpenCms中使用jsp forward

本来想在opencms项目中构建MVC结构的架构,当使用forward转发页面时,总是返回空白页。

查阅了好多资料才发现官方文档给出了说明:

What about using <jsp:forward page="..." /> with OpenCms?

Again, the short answer is:  It currently doesn't work in OpenCms, so don't use it. You should consider using the OpenCms tablib (or scriptlet API) to achieve your results.

The long answer is: As described above, OpenCms loads any JSP with an internal requestDispatcher("{file.jsp}").include() call. It expects to get the control back after that include call. This is not the case when you use <jsp:forward /> , as the final page will terminate the request. This currently causes the JSP integration in OpenCms to break. We hope to provide that feature in a future OpenCms release. Note that the filename adjustment issue described above also applies to the forward tag.


意思就是目前在opencms中根本不能用 forward。

我的解决方案是:

建立一个类,在其中使用属性表明其作用域(request or session),然后把这一对象存放在session中传递,使用sendRedirect转发页面。如果作用域表明:request,则在获得这一对象后在session中移除该对象。

你可能感兴趣的:(jsp,mvc)