为什么80%的码农都做不了架构师?>>>
摘要:JSP文件过大无法编译,后台抛异常Generated servlet error:The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit,建议修改web.xml加入初始化参数,应该能有所改善。
问题描述
项目中使用SCE表单,字段很多,使用的控件多,造成JSP文件过大,在表单预览时后台抛异常The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit。
[super][2014-10-16 11:41:15,794][ERROR][org.gocom.components.coframe.policy.RulesIpFilter:49] Error to Filter url of http://www.bb.mac:8080/super/ap_web/ZY09A/ZY09A_1__form.jsp
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
......
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:695)
Caused by: org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
... 73 more
解决方案
空行的去除没有帮助,减少引用的js会有小帮助,但在jsp本身很大的时候作用有限。建议尝试修改应用服务器的web.xml文件(在tomcat下位于conf目录下,在jboss下位于server\default\deploy\jbossweb.sar目录下 ),修改如下图所示之处,加入红框内的初始化参数。