ColdFusion: about using custom quot;own writtenquot; Java classes(ColdFusion:关于使用定制的“自己写的;Java 类)
问题描述
我需要在 cfml 页面中使用我自己的 java 类.
I need to use my own java class in a cfml page.
文档中的这个条目听起来不错,但是没有解释我必须创建哪些文件.
This entry in the documentation sounds great but does not explain which files I have to create.
我试图在我的网站根目录下创建一个 test.cfm
页面.然后将 TestClass.java
+ TestClass.class
放在同一路径下.但这会导致错误找不到类"!.
I tried to create a test.cfm
page under my website root. Then placed TestClass.java
+ TestClass.class
in the same path. But that results in an error "class not found"!.
你能帮帮我吗?
推荐答案
TestClass.java + TestClass.class 在同一路径中.
a TestClass.java + TestClass.class in the same path.
您不能只将 .class
文件放在任何地方.当 CF 服务器启动时,它仅检查类/jar 的特定位置.这些位置称为CF 类路径".你编译的.class
文件必须放在CF类路径中,否则检测不到.
You cannot just place .class
files anywhere. When the CF server starts, it only checks specific locations for classes/jars. Those locations are referred to as the "CF class path". Your compiled .class
file must be placed within the CF class path, or it will not be detected.
使用自定义 java 类:
To use a custom java class:
- 创建一个源文件即
YourTestClass.java
- 将源代码编译成类文件即
YourTestClass.class
将编译好的
.class
文件放在CF类路径的某处,如:
- Create a source file ie
YourTestClass.java
- Compile the source code into a class file ie
YourTestClass.class
Place the compiled
.class
file somewhere within the CF classpath, such as:
WEB-INFclasses
- 用于单个.class
文件WEB-INFlib
- 用于.jar
文件(多个类)
WEB-INFclasses
- for individual.class
filesWEB-INFlib
- for.jar
files (multiple classes)
注意:您还可以通过 ColdFusion 管理员.但是,将类放在默认目录之一更简单.
Note: You could also add the item to the CF class path via the ColdFusion Administrator. However, placing the class in one of the default directories is simpler.
重启 ColdFusion 服务器以检测新类
Restart the ColdFusion server so it detects the new classes
注意:虽然您可以使用单独的 .class
文件,但更常见的是将它们打包成 .jar
文件.
Note: Though you can use individual .class
files, it is more common to package them into .jar
files.
这篇关于ColdFusion:关于使用定制的“自己写的";Java 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ColdFusion:关于使用定制的“自己写的";Java 类


- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01