什么是.jspf文件扩展名?怎么编译呢? [英] What is .jspf file extension? How to compile it?

查看:136
本文介绍了什么是.jspf文件扩展名?怎么编译呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSP中的.jspf文件是什么?我知道编译器会查找.jsp文件进行编译,然后如何编译.jspf文件?

What are .jspf files in JSP? As I know the compiler will look for .jsp files to compile, then how are the .jspf files compiled?

推荐答案

和其他人一样已经注意到,.jspf文件是JSP片段。它们被设计为静态包含在另一个JSP文件中,而不是自己编译:

As others have noted, .jspf files are JSP fragments. They're designed to be statically included in another JSP file, not compiled on their own:

<%@include file="/WEB-INF/jspf/example.jspf" %>

你会注意到这个例子来自 / WEB-INF / jspf 目录。这意味着它无法在Web应用程序之外访问;没有办法构建一个可以检索它的URL。如果将它们放在与普通JSP文件相同的目录中,则可以构造这样的URL;例如,Tomcat将页面检索为文本文档。但是,前端Web服务器可以阻止这些URL。

You'll note that this example comes from the /WEB-INF/jspf directory. This means that it is not accessible outside of the web application; there's no way to construct a URL that can retrieve it. If you put them in the same directory as "normal" JSP files, you can construct such a URL; Tomcat, for example will retrieve the page as a text document. A front-end web-server, however, can block these URLS.

我喜欢JSPF文件作为重构大型JSP页面。由于它们是静态包含的,因此您可以提取文件的一小部分,而无需提供脚本或变量,从而使页面更易于维护(我想强调,它是第一个步骤;动态包含和taglib通常是更好的长期解决方案)。在重构时,我相信保持片段接近其父文件;这是一个阻止URL的网络服务器变得有用的时候。

I like JSPF files as a first step in refactoring large JSP pages. Since they're statically included, you can extract a small chunk of the file without making provision for scriptets or variables, leading to pages that are somewhat more maintainable (and I want to stress, it's a first step; dynamic includes and taglibs are usually a better long-term solution). When refactoring, I believe in keeping the fragments close to their parent files; this is when having a web-server to block URLs becomes useful.

这篇关于什么是.jspf文件扩展名?怎么编译呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆