在Tomcat 8 Ant脚本中预编译JSP

时间:2017-05-03 10:37:18

标签: java jsp tomcat ant precompile

我有一个带有Sprint框架的Java应用程序。所有页面都由Controller访问,Controller处理请求并返回带有几个参数的jps ModelAndView以在JSP文件中呈现。

您知道预先编译这些JSP文件的方法吗?我能够使用此ant script生成* _jsp.java文件,但是我尝试编译为.class时出现编译错误,如下所示:

symbol:   method getELContext()
  location: variable _jspx_page_context of type PageContext
/home/user/apache-tomcat-8.5.14/webapps/project/WEB-INF/src/org/apache/jsp/WEB_002dINF/views/awarding/awarding_005finput/detail/applicant/awardingInputDetailApplicant_jsp.java:683: error: cannot find symbol
      _jspx_th_c_005fset_005f5.setValue(new org.apache.jasper.el.JspValueExpression("/WEB-INF/views/awarding/awarding_input/detail/applicant/awardingInputDetailApplicant.jsp(68,5) '${!applicant.hasAnyConfirmedCandidacyGoal()}'",_jsp_getExpressionFactory().createValueExpression(_jspx_page_context.getELContext(),"${!applicant.hasAnyConfirmedCandidacyGoal()}",java.lang.Object.class)).getValue(_jspx_page_context.getELContext()));

所有错误都与"符号有关:方法getELContext()" ...

更新

这是我用来从jasper任务生成的* _jsp.java编译jsp的Ant任务:

<target name="compileJSPs">
        <mkdir dir="${tomcat.home}/work/Catalina/localhost/${project.name}/WEB-INF/classes"/>
        <mkdir dir="${tomcat.home}/work/Catalina/localhost/${project.name}/WEB-INF/lib"/>
        <javac destdir="${tomcat.home}/work/Catalina/localhost/${project.name}/WEB-INF/classes"
               optimize="off"
               debug="on" failonerror="false"
               srcdir="${webapp.path}/WEB-INF/src"
               excludes="**/*.smap">
            <classpath>
                <pathelement location="${webapp.path}/WEB-INF/classes"/>
                <fileset dir="${webapp.path}/WEB-INF/lib">
                    <include name="*.jar"/>
                </fileset>
                <pathelement location="${tomcat.home}/lib"/>
                <fileset dir="${tomcat.home}/lib">
                    <include name="*.jar"/>
                </fileset>
                <fileset dir="${tomcat.home}/bin">
                    <include name="*.jar"/>
                </fileset>
            </classpath>
            <include name="**"/>
            <exclude name="tags/**"/>
        </javac>
    </target>

这里我附上我的tomcat_home / lib包含:

Tomcat Home libs included

0 个答案:

没有答案