??xml version="1.0" encoding="utf-8" standalone="yes"?>一本色道久久综合亚洲精品酒店,欧美久久久久久久,国产精品福利在线观看网址http://www.aygfsteel.com/JavaZero/category/37487.htmlTo feel the crazy worldzh-cnFri, 06 Feb 2009 11:12:55 GMTFri, 06 Feb 2009 11:12:55 GMT60The solution of problem: "code too large for try statement"http://www.aygfsteel.com/JavaZero/archive/2009/02/06/253623.htmlKenLeeKenLeeFri, 06 Feb 2009 10:33:00 GMThttp://www.aygfsteel.com/JavaZero/archive/2009/02/06/253623.htmlhttp://www.aygfsteel.com/JavaZero/comments/253623.htmlhttp://www.aygfsteel.com/JavaZero/archive/2009/02/06/253623.html#Feedback0http://www.aygfsteel.com/JavaZero/comments/commentRss/253623.htmlhttp://www.aygfsteel.com/JavaZero/services/trackbacks/253623.html今天到了个比较奇怪的问题,居然是因为JSP太大D文g~译不了,上网查了一?把解x法脓(chung)下来,以供以后参?

The problem is that there is a limit on the size of a compiled method in a
Java class file, and that limit is what we're running up against. Recall
that a JSP page is compiled into a servlet, and into essentially only one
method in that servlet. Hence, if your page contains many, many tags, that
method becomes too big, and up comes the exception that you're seeing.

There are a couple of (partial) solutions.

1) Break your giant page up into multiple smaller pages and bring them
together at run time using <jsp:include>. Note that <%@include> won't work,
because that's a compile-time include, which will get you straight back to
the original problem.

2) Look for places to save on tags. For example, the <html:option> tag was
recently extended to allow the specification of the text to display, so
that you can replace this:

<html:option ... ><bean:message key="foo"/></html:option>

with this:

<html:option ... key="foo"/>

More info pls access this link: Solution

我就是用了第一U方法解决的,之前include JSP的时候用?a href="mailto:%@include">%@include, 后来用了<jsp:include>׃会用问题?Z贴一下两者的区别:


<%@ page language="java" contentType="text/html" %>
<html>
<head>
      <title>newInstance.com</title>
      <meta http-equiv="Content-Type"
        content="text/html; charset=iso-8859-1" />
      <link href="/styles/default.css"
        rel="stylesheet" type="text/css" />
</head>
<body>
<%@ include file="header.jsp" %>
<%@ include file="navigation.jsp" %>
<%@ include file="bookshelf.jsp" %>
<%@ include file="/mt-blogs/index.jsp" %>
<%@ include file="footer.jsp" %>
</body>
</html>


虽然 include 非常适于静态内容ƈ?Web 面Q但对于动态内容却不尽如h意。我们在前一文章中在试N新装入高速缓存文件时发现了这一问题。与大多数页眉文件及脚文g不同Q动态内容变化频J,必须时刻更新。我们将首先D地重qC?include 伪指令的局限性,然后我将向?zhn)演示如何?jsp:include 标记来扩?JSP 的包含能力?/p>


高速缓存问?/p>

JSP include 伪指令的不之处有一个是Q它会导?Web 览器高速缓存所有页面。在处理诸如脚、版权声明或一l静态链接之cȝ静态组件时Q这是有意义的。这些文件不会改变,因此没有理由?JSP 解释器不断地重新轮询其中的数据。凡是可能的地方Q都应该实现高速缓存,因ؓ它改善了应用E序的性能?/p>


但是Q有时侯Q进行高速缓存会得不偿失。如果提入的内容来自使用动态数据(?Weblog 或数据库驱动?JSP 文gQ的E序Q甚臛_果所包含的内Ҏ(gu)l常变化?HTMLQ如旉戌Q,那么每当装入 Web 面Ӟ都需要显C些文件或E序的最新版本。遗憄是,JSP include 伪指令ƈ不具备这一功能。在试和开发周期中Q在览器中用高速缓存通常能够解决q一问题。但是,对于实际使用的应用程序而言Q性能是Q何设计决{过E中的一w要因素,用高速缓存ƈ不是一U可行的长远之计。更好的解决Ҏ(gu)是?jsp:include 标记?/p>

jsp:include 标记

jsp:include 只不q是一个不同于 include 的伪指o而已?jsp:include 的优点在于:?L会检查所含文件中的变化。过一会儿我们研I这一新标记的工作方式。但首先看一下两U?include 各自的代码,以便能够看到二者之间的异同?/p>

清单 2 昄了一个简单页面,它用了原始?JSP include 伪指令?/p>


清单 2. JSP include 伪指?br />
<%@ page language="java" contentType="text/html" %>
<html>
     <head>
      <title>JSP include element test</title>
     </head>
     <body>
      This content is statically in the main JSP file.<br />
      <%@ include file="included.html" %>
     </body>
</html>


清单 3 是同一个页面,只不q这里{成?jsp:include 标记?/p>


清单 3. 转成使用 jsp:include

<%@ page language="java" contentType="text/html" %>
<html>
     <head>
      <title>JSP include element test</title>
     </head>
     <body>
      This content is statically in the main JSP file.<br />
      <jsp:include page="included.html" flush="true" />
     </body>
</html>


(zhn)应该注意这两种代码cd之间的两大区别。首先, jsp:include 元素不用属?include 伪指令的 %@ 语法。实际上Q?jsp 前缀?JSP ~译器知道:它应该寻找标?JSP 标记集中的元素。其ơ,指定要包含的文g的属性从 file 变成?page ?/p>


flush 属?/p>

(zhn)可能已注意?jsp:include 代码CZ中的 flush 属性。顾名思义Q?flush 指示在读入包含内容之前是否清IZQ何现有的~冲区。JSP 1.1 中需?flush 属性,因此Q如果代码中不用它,会得C个错误。但是,?JSP 1.2 中, flush 属性缺省ؓ false。由于清I大多数时候不是一个重要的问题Q因此,我的是:对于 JSP 1.1Q将 flush 讄?trueQ而对?JSP 1.2 及更高版本,其讄为关闭?/p>


jsp:include 是如何工作的

如果(zhn)有点爱刨根问底Q那么可能十分想知道 jsp:include 标记的行Zؓ什么与 include 伪指令不同。道理其实十分简单: jsp:include 包含的是所包含 URI ?响应Q而不?URI 本n。这意味着Q对所指出?URI q行 解释Q因而包含的?生成的响应。如果页面是 HTMLQ那么将得到一点也没有变化?HTML。但是,如果?Perl 脚本、Java servlet 或?CGI E序Q那么得到的是从该E序解释而得的结果。虽焉面通常是 HTMLQ但实际E序恰好是达到目的的手段。而且Q由于每ơ请求页面的时候都会进行解释,因此从来不会象?include 伪指令时那样高速缓存结果。虽然这只是很小的变动,但它却导致了(zhn)所见到的行Z的全部差异?/p>


一U؜合搭配的解决Ҏ(gu)

include 伪指令在某些|站上有其用武之地。例如,如果站点包含一些(如果有变化,也很)几乎没有变化的页眉、页脚和D文gQ那么基本的 include 伪指令是q些lg的最佳选项。由?include 伪指令采用了高速缓存,因此只需攑օ包含文g一ơ,其内容就会被高速缓存,其结果会是极大地提高了站点的性能?/p>

然而,对于现在许多 Web 应用E序或站点而言Q地毯式的高速缓存ƈ不能解决问题。虽焉眉和脚可能是静态的Q但是不可能整个站点都是静态的。例如,从数据库提取D链接是很常见的,q且许多Z JSP 技术的站点q从其它站点或应用程序上的动?JSP 面提取内容。如果正在处理动态内容,那么需要采?jsp:include 来处理该内容?/p>

当然Q最好的解决Ҏ(gu)是经常把q两U方法؜合搭配用,每U构造用到最恰当的地斏V清?4 是؜合搭配包含解x案的一个示例?/p>

清单 4. 混合搭配解决Ҏ(gu)

<%@ page language="java" contentType="text/html" %>
<html>
<head>
<title>newInstance.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="/styles/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<jsp:include page="header.jsp" flush="true">
<jsp:param name="pageTitle" value="newInstance.com"/>
<jsp:param name="pageSlogan" value=" " />
</jsp:include>
<%@ include file="/navigation.jsp" %>
<jsp:include page="bookshelf.jsp" flush="true" />
<jsp:include page="/mt-blogs/index.jsp" flush="true" />
<%@ include file="/footer.jsp" %>
</body>
</html>


上面的代码显CZ前一文章中的示例烦引页面。导航链接和脚是静态内容,一q最多更改一ơ。对于这些文Ӟ我用了 include 伪指令。内容窗格包?Weblog ?#8220;bookshelf”lgQ它们是动态生成的。这两个lg需要一直更斎ͼ因此对它们,我用了 jsp:include 标记?header.jsp 文g有点奇怪。这个组件是从另一个本质上是静态的 JSP 面提取的。但是,正如(zhn)将注意到的那样Q它从包含页提取?#8220;标语”Q然后将它显C出来。要处理q一׃n信息Q我们必d늜文g传入参数。而要处理那些参数Q就必须使用 jsp:include 元素?/p>

 
后记:|上q有一USolution:

try giving this in the deployment descriptor.

<jsp-param>
<param-name>noTryBlocks</param-name>
<param-value>true</param-value>
</jsp-param>

本h没有试过, 不知好不好用....



KenLee 2009-02-06 18:33 发表评论
]]>
վ֩ģ壺 | | Ұ| | | ɫ| | Ҿ| | | | ÷| ̨| ƽ| ʩ| | | ¡| | ͬ| ֳ| ؼ| | | | | ƺ| Ʊ| ѧ| | | | ľ| ̨| ɣ| | | Ȩ| | ޶| |