tomcat-load-jsp

tomcat解决加载JSP文件过大错误

标签(tomcat jsp ): tomcat


当遇到多个Jsp include一起的时候加载时遇到如下错误:

Error:SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: [136] in the generated java file: ****
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit

解决:
1.修改tomcat配置:打开tomcat路径—conf—web.xml。
2.直接搜索关键字‘xpoweredBy’再加一个init-param初始化参数配置如下:

<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
        <param-name>genStrAsCharArray</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>mappedfile</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>development</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>fork</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>xpoweredBy</param-name>
        <param-value>false</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
</servlet>

3.保存退出,删除eclipse中的tomcat配置重新添加即可。
4.注意大小写mappedfile

热评文章