本文介绍了方法代码...超过65535字节限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jsp中我有一个小标题:

Inside a jsp I have a small header :

<%@ page import="java.util.*"%>

<% HttpSession CurrentSession =
 request.getSession();
 ...
%>

...和一个大的html

...and a big html

<html>
...
</html>

如果我尝试按原样读取它,我会收到错误...超过65535字节限制。我必须分解它。因为我是java新手,我无法弄明白该怎么做。请你指点我的方式?

If I try to read it as is I get an error of "...is exceeding the 65535 bytes limit".I have to break it up.Since I am new to java I cannot figure it out how to do it.Could you please indicate me the way?

推荐答案

JSP被编译成servlet代码,然后编译成实际的java .class文件。 JSP代码将被放入一个大的doGet()方法中,如果您的JSP文件非常大,它将达到65535的方法大小限制。该限制来自(code_length项目的值必须小于65536 )。

JSPs get compiled into servlet code, which are then compiled into actual java .class files. JSP code will be put into one big doGet() method, and if your JSP file is really big, it will hit the method size limit of 65535. The limit is coming from JVM specification ("The value of the code_length item must be less than 65536").

您应该将文件拆分为多个文件。我不会将它拆分为此线程中提出的不同方法,因为它可以使代码逻辑在这种情况下更加复杂,但是对于HTML部分执行jsp:include,例如。

You should split the file into several files. I wouldn't split it into different methods as proposed in this thread, since it can make the code logic even more complex in this case, but do a jsp:include for the HTML part(s) like proposed by McDowell.

这篇关于方法代码...超过65535字节限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 16:53