重新加载jsp页面时出现字节限制问题?
我是 jsp 新手。我收到的错误是方法的代码 _jspService(HttpServletRequest, HttpServletResponse) 超出了 65535 字节限制
我正在使用静态包含,例如
<%@ include file="/jsp/common/createScriptMsg.jsp" %>
但页面未加载... 我还会尝试动态包含,例如
<jsp:include page="/jsp/common/createScriptMsg.jsp" /> \
NO LUCK..
任何帮助将不胜感激。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我们通过在 Tomcat 配置中将 JspServlet 的
mappedfile
设置为false
来“修复”这个问题。转到
%TOMCAT_HOME%/conf/web.xml
并将以下 init-param 添加到 JspServlet:这不会解决 64 KiB 限制,但会以这种方式帮助解决该问题很多< /em> 稍后,因为生成的代码更短。
We "fixed" this here by setting
mappedfile
tofalse
for JspServlet in our Tomcat-Config.Go to
%TOMCAT_HOME%/conf/web.xml
and add the following init-param to the JspServlet:This does not solve the 64 KiB limit but helps in that way that it occurs much later because the generated code is shorter then.
我发现上面提到的答案的解决方案更好,而不是制作多个文件,即添加
到 Web.XML 文件中。但我在 web.XML 文件中没有找到“JspServlet”,并发现
“ rel="nofollow">参考链接 并放置了对我有用的 。希望这会对某人有所帮助。
Rather making multiple files i found above mentioned answer's solution more good i-e Adding
into Web.XML file. but i did not found "JspServlet" in my web.XML file and found a ref link and placed the complete mapping
that worked for me. hope this will help someone.
我从昨天开始就遇到了这个问题,我使用动态 include 将我的 JSP 分成两个 JSP,但它本身并没有帮助我,请确保您还添加了所有标签 lib 和导入声明。 像一个函数一样工作,因此,如果您将 JSP 分成两个或多个,它们需要与原始 JSP 中相同的导入。希望它对你有用,对我有用。
I have been having this problem since yesterday, I split my JSP into two JSPs using dynamic include
<jsp:include
,but it alone didn't help me, Make sure you also add all tags lib and import statement.<jsp:include
works like a function, So if you are breaking up your JSP in two or more they require same import which you have in your original JSP. Hope it works for you, it worked for me.当您运行 Jsp 时,默认情况下它会转换为 java 代码。在 Java 中,单个 try catch 循环中只能容纳 65K 代码。所以不要在单个jsp中放入太多代码,而是可以将多个Jsp文件导入到单个jsp文件中。
或者使用 JSTL。
When you run Jsp, by default it converts into java code. And in Java, only 65K code can be accommodated inside an single try catch loop. So don't put much code in a single jsp, instead you can import the number of Jsp files into an single jsp file.
or else use JSTL.
以防其他人偶然发现这一点,就我而言,这只是一个 JSP,其中包含其他 JSP 文件的多个包含语句(其中一些不止一次),因此只需检查所有内容是否都包含在解决问题后即可。
In case anyone else stumbles on this, in my case, it was just a JSP with multiple include statements of other JSP files (and some of them more than once), so just checking that everything was included once solved the problem.
我在 tomcat web xml 中也添加了 trimSpaces true 作为 init-param ,它解决了问题。
I have added trimSpaces true also as init-param in tomcat web xml and it resolved the issue.
将一些逻辑从 JSP 页面移出并移至专用 bean 中。
每个 Java 方法 65k 字节的限制非常高,只有非常非常长的方法超过它。
另请注意,任何强常量的长度不包含在该方法中,因此您在该单个方法中只是有一些荒谬的逻辑量(注意:JSP 被编译成 Servlet,其中
_jspService
方法保存 JSP 的主要内容)。所以你的逻辑太多了。您的 JSP 中根本不应该有任何逻辑(仅输出呈现)。
另请注意, 只是在这种情况下执行同一操作的两种不同方法,因此不会产生任何影响。
<%@ include
和Move some of the logic out of your JSP pages and into dedicated beans.
The limit of 65k bytes per Java method is insanely high and only very, very long methods exceed it.
Note also that the length of any strong constants is not included in that method, so you simply have some absurd amount of logic in that single method (note: JSPs are compiled into Servlets, wher the
_jspService
method holds the main bulk of the content of the JSP).So you simply have too much logic. You shouldn't have any logic in your JSP at all (only output rendering).
Also note that
<%@ include
and<jsp:include
are simply two different ways to do the same thing in this case, so that won't make a difference.