将WAR文件中的Java Server Pages(JSP)编译为Class文件 [英] Compiling Java Server Pages (JSP) in a WAR file to Class files

查看:73
本文介绍了将WAR文件中的Java Server Pages(JSP)编译为Class文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从源代码生成的测试WAR文件.解压缩WAR文件时,我看到Java类已编译为.class文件,但.jsp文件未编译.我知道这是在运行时完成的,最终将.jsp文件转换为.class文件.

我在Tomcat7中开发了我的WAR文件.我意识到这是一个奇怪的问题.最终目标是开发一种可在类文件(我无法读取jsp文件)上运行的静态分析工具.

我已经阅读到可以优化WAR文件并将JSP文件预编译为嵌套在WAR文件中的JAR文件的方法,但是我不知道该怎么做.我想找到或创建一个使用未优化的WAR文件并生成JSP类文件的实用程序.

解决方案

是的,JSP通常是即时生成的.在Tomcat中,它是由 Jasper JSP引擎完成的. /p>

可以预编译它们.本文可能会帮助您:如何预编译JSP

它描述了如何从命令行触发预编译,并包括一个示例Ant文件.

I have a test WAR file that I generated from source. When I unzip the WAR file I see that the Java classes were compiled to .class files, but the .jsp files were not compiled. I understand this is done at runtime and the .jsp files are eventually converted to .class files.

I developed my WAR file in Tomcat7. I realize this is an odd question. The end goal is to develop a static analysis tool which runs on class files (I cannot read jsp files).

I've read that I can optimize the WAR file and precompile the JSP files into a JAR file that is nested in the WAR file, but I can't figure out how to do it. I'd like to find or create a utility that takes an unoptimized WAR file and generates the JSP class files.

解决方案

Yes, JSPs are normally generated on the fly. In Tomcat, it is done by the Jasper JSP engine.

It is possible to pre-compile them. This article might help: How to pre-compile JSP

It describes how to trigger the pre-compilation from the command line and includes an example Ant file.

这篇关于将WAR文件中的Java Server Pages(JSP)编译为Class文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆