http://yulimin.iteye.com/blog/412504
引子:
在WAS当中是通过
- com.ibm.websphere.ant.tasks.JspC
完整的Ant脚本 build.xml 文件内容
- <?xmlversion="1.0"encoding="UTF-8"?>
- <projectname="WASJSPPreCompile"default="jspc"basedir=".">
- <propertyname="was.home"location="D:/IBM/WebSphere/AppServer"/>
- <propertyname="webapp.path"location="D:/IBM/WebSphere/AppServer/installableApps/DefaultApplication/DefaultWebApplication"/>
- <propertyname="jspc.path"location="${webapp.path}/jspc"/>
- <!--是否保留生成的.java文件-->
- <propertyname="java.keep"value="true"/>
- <!--;${was.home}/runtimes/com.ibm.ws.webservices.thinclient_6.1.0.jar-->
- <propertyname="jsp.classpath"value="${was.home}/lib/bootstrap.jar;${was.home}/lib/startup.jar;${was.home}/lib/j2ee.jar"/>
- <targetname="make-dir">
- <mkdirdir="${jspc.path}"/>
- </target>
- <!--定义WASJSP预编译任务-->
- <taskdefname="wsjspc"classpath="${was.home}/plugins/com.ibm.ws.runtime_6.1.0.jar"classname="com.ibm.websphere.ant.tasks.JspC"/>
- <!--调用WASJSP预编译工具,进行对JSP进行编译-->
- <targetname="jspc"depends="make-dir">
- <wsjspcwasHome="${was.home}"src="${webapp.path}"toDir="${jspc.path}"forcecompilation="true"verbose="true"deprecation="false"loglevel="CONFIG"keepgenerated="${java.keep}"classpath="${jsp.classpath}"/>
- </target>
- <propertyname="ear.path"location="D:/IBM/WebSphere/AppServer/installableApps/DefaultApplication.ear"/>
- <propertyname="extract.dir"location="${was.home}/temp/DefaultApplication.earextract"/>
- <!--编译整个EAR-->
- <targetname="jspcEar">
- <mkdirdir="${extract.dir}"/>
- <wsjspcwasHome="${was.home}"earpath="${ear.path}"forcecompilation="true"extractToDir="${extract.dir}"useThreadTagPool="true"keepgenerated="${java.keep}"jspCompileClasspath=""classpath="${jsp.classpath}"loglevel="CONFIG"/>
- </target>
- </project>
注意:就是多了一个包就会编译不出来,汗。。。看我注释掉的那个jar包:
- com.ibm.ws.webservices.thinclient_6.1.0.jar
运行仍会提示:
无法语法分析 setupCmdLinE: null\bin\setupCmdLine.bat (系统找不到指定的路径。)
直接无视它即可。
编译成功的话会有:
1、ant jspc
[wsJspC] _internalCompileApp() returning returnCode: [0]
[wsJspC] JSPG0151I: 返回码:0
[wsJspC] JSPG0168I: 批处理编译器成功退出并且没有错误。
2、ant jspcEar
[wsJspC] JSPG0187I: 保存已完成。
[wsJspC] JSPG0168I: 批处理编译器成功退出并且没有错误。
如果有问题最好是通过
- ant-verbose
来查看详细的错误再进行对应的分析即可。
BTW:我的测试环境是:Windows XP SP3 + WAS 6.1.0.23
并直接编译 DefaultApplication.ear 解开的jsp与整个ear包成功。
更多关于wsJspC的信息请参考InfoCenter:
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.base.doc/info/aes/ae/rweb_jspant.html