重新加载jsp页面时出现字节限制问题?

发布于 2024-12-06 02:47:38 字数 367 浏览 1 评论 0 原文

我是 jsp 新手。我收到的错误是方法的代码 _jspService(HttpServletRequest, HttpServletResponse) 超出了 65535 字节限制

我正在使用静态包含,例如

<%@ include file="/jsp/common/createScriptMsg.jsp" %> 

但页面未加载... 我还会尝试动态包含,例如

<jsp:include page="/jsp/common/createScriptMsg.jsp" /> \

NO LUCK..

任何帮助将不胜感激。

Im new to jsp.I'm getting error is The code of method
_jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit

I am using static include such as

<%@ include file="/jsp/common/createScriptMsg.jsp" %> 

but the page is not loading ...
I'd also try dynamiac include such as

<jsp:include page="/jsp/common/createScriptMsg.jsp" /> \

NO LUCK..

Any help would be appriciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

并安 2024-12-13 02:47:38

我们通过在 Tomcat 配置中将 JspServlet 的 mappedfile 设置为 false 来“修复”这个问题。
转到 %TOMCAT_HOME%/conf/web.xml 并将以下 init-param 添加到 JspServlet:

    <init-param>
        <param-name>mappedfile</param-name>
        <param-value>false</param-value>
    </init-param>

这不会解决 64 KiB 限制,但会以这种方式帮助解决该问题很多< /em> 稍后,因为生成的代码更短。

We "fixed" this here by setting mappedfile to false for JspServlet in our Tomcat-Config.
Go to %TOMCAT_HOME%/conf/web.xml and add the following init-param to the JspServlet:

    <init-param>
        <param-name>mappedfile</param-name>
        <param-value>false</param-value>
    </init-param>

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.

亚希 2024-12-13 02:47:38

我发现上面提到的答案的解决方案更好,而不是制作多个文件,即添加

<init-param>
        <param-name>mappedfile</param-name>
        <param-value>false</param-value>
    </init-param>

到 Web.XML 文件中。但我在 web.XML 文件中没有找到“JspServlet”,并发现

 <servlet>
         <servlet-name>jsp</servlet-name>
         <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param> 
            <param-name>mappedfile</param-name>
             <param-value>false</param-value>
        </init-param>
     </servlet> 

“ rel="nofollow">参考链接 并放置了对我有用的 。希望这会对某人有所帮助。

Rather making multiple files i found above mentioned answer's solution more good i-e Adding

<init-param>
        <param-name>mappedfile</param-name>
        <param-value>false</param-value>
    </init-param>

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

 <servlet>
         <servlet-name>jsp</servlet-name>
         <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param> 
            <param-name>mappedfile</param-name>
             <param-value>false</param-value>
        </init-param>
     </servlet> 

that worked for me. hope this will help someone.

私藏温柔 2024-12-13 02:47:38

我从昨天开始就遇到了这个问题,我使用动态 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:includeworks 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.

Saygoodbye 2024-12-13 02:47:38

当您运行 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.

海的爱人是光 2024-12-13 02:47:38

以防其他人偶然发现这一点,就我而言,这只是一个 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.

浅唱々樱花落 2024-12-13 02:47:38

我在 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.

我纯我任性 2024-12-13 02:47:38

将一些逻辑从 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文