一个大的包含文件或几个小的

一个大的包含文件或几个小的

本文介绍了一个大的包含文件或几个小的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写的一些jsp和我想知道是否这将是最好能有一个大的包含文件,我将包括每一个页面或几个较小的需要,我将只包括在某些页面。




任何给定的页将只需要至多调用一些方法(小于5)。如果我使用一个文件,这将是2500 +线code的。




我最关心的是有关与维护是次要的表现。




我们使用JSP include指令<%@ include文件=FileToInclude%GT;




编辑:我会做的ASP页面同样的事情,以及

I am writing some jsp and I am wondering if it would be better to have one large include file that I would include with every page or several smaller ones that I would include only on certain pages as needed.

Any given page will only need to call a few methods at most ( < 5). If I use one file, it would be 2500+ lines of code.

My main concern would be about performance with a secondary concern on maintenance.

We are using the jsp include directive <%@ include file="FileToInclude" %>

I will be doing the same thing for asp pages as well.

推荐答案

这将被包含在每一个 JSP什么,随意添加到一个包含文件。对于东西,将被包括在JSP中只有一小部分,创建单独的文件,包括那些。

Anything that will be included in every JSP, feel free to add to a single included file. For stuff that will be included on only a small minority of JSPs, create separate included files for those.

巨大JSP是保持熊市。

Enormous JSPs are a bear to maintain.

更妙的是,然而,正在尽可能多code尽可能的退出中的JSP和你的域对象或到模型或在你的servlet。凡是是纯Java通常属于没有在JSP但在你的JAR文件:

Even better, however, is moving as much code as possible out of the JSPs and into your domain objects or into your model or in your servlets. Anything that is pure Java usually belongs not in the JSP but in your JAR files:


  1. 的IDE做导航和重构纯Java code的工作做得更好。

  2. 当JSP的大多是HTML和JSP标记(用尽可能少的Java code越好),他们变得​​更容易维护和理解。
  3. 这是容易理解的纯Java,因为在混合没有HTML标记。

  4. 这使得JSP页面更容易理解与Java code一块巨大的被替换用很短的调用Java的code。

  5. 这使得维护您的JSP更容易未做保养您的code群更加困难。

这篇关于一个大的包含文件或几个小的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 02:14