如何实现 jsp:include

    技术2022-05-11  133

    如果你想在 jsp 页面中包含另一个页面,标准的方式是使用 <jsp:include> 标签。不过还有一种用 sciptlet 实现同样效果的方式: <% out.flush();request.getRequestDispatcher( "fragment.jsp" ).include(request, response);%> 这么做有什么用呢?比如你想在 Servlet 里面写上一堆 html,而字符串的拼凑实在是麻烦。你现在可以把这些 html 内容单独放在 html 或者 jsp 文件里面,通过这两行调用即可。 至于第一句是做什么用的,你不妨去掉看看~~

    最新回复(0)