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

查看:25
本文介绍了.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 会将页面检索为文本文档.但是,前端网络服务器可以阻止这些 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 页面的第一步.由于它们是静态包含的,因此您可以提取一小块文件而无需提供脚本或变量,从而使页面更易于维护(我想强调的是,这是第一步; 动态包含和标记库通常是更好的长期解决方案).重构时,我相信让片段靠近它们的父文件;这就是使用网络服务器来阻止 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天全站免登陆