【问题标题】:Spring boot _jspService is exceeding the 65535 bytes limitSpring boot _jspService 超出 65535 字节限制
【发布时间】:2018-06-10 14:15:44
【问题描述】:

我收到以下错误

_jspService(HttpServletRequest, HttpServletResponse) 超过了 65535 字节的限制

我知道对于 Apache Tomcat,tomcat 的 web.xml 中的以下标记可以解决问题

<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>

但我使用 嵌入式 tomcatSpring Boot。 所以没有web.xml 我不确定此配置是否可行,或者是否有其他解决方法。

【问题讨论】:

标签: jsp spring-boot web.xml embedded-tomcat-8


【解决方案1】:

我知道这是一个迟到的答案,但我偶然发现了与 jsp、spring boot 和嵌入式 tomcat 相同的问题,下面是拯救我一天的简单解决方案。

在spring boot “application.properties”文件中添加以下属性并重启服务器,应该可以解决问题-

server.servlet.jsp.init-parameters.mappedfile=false

【讨论】:

    【解决方案2】:

    使用WebServerFactoryCustomizer&lt;TomcatServletWebServerFactory&gt;自定义JspServlet初始化参数ma​​ppedfilefalse

    下面的示例代码覆盖了 WebServerFactoryCustomizer

    的自定义方法
    public void customise(TomcatServletWebServerFactory factory) {
         factory.getJsp().setInitParameters(..);
    }
    

    理想情况下,您可以通过避免在 JSP 中使用以下语句来最小化生成的 servlet 大小

    <%@ include file="display.jsp" %>
    

    并在下面使用

    <jsp:include page="display.jsp" />
    

    【讨论】:

      猜你喜欢
      • 2023-03-24
      • 1970-01-01
      • 2020-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-10
      相关资源
      最近更新 更多