jfinal-enjoy 5.2.2 的python 3.9.0 实现,基于jpype1实现。 实现:mrzhou@miw.cn
Project description
py-enjoy
jfinal-enjoy 5.2.2 的python 3.9.0 实现,基于jpype1实现。 python port by mrzhou@miw.cn
使用样例
示例1:使用项目内置的jar文件(推荐)
from enjoy import Enjoy
if __name__ == "__main__":
# 1. 配置参数(仅需配置模板路径)
TEMPLATE_BASE_PATH = "./templates" # 模板文件所在目录(如index.html放在这个目录下)
# 2. 创建Enjoy实例(初始化Engine,自动使用内置的enjoy-5.2.2.jar)
try:
enjoy = Enjoy(
template_base_path=TEMPLATE_BASE_PATH
)
示例2:指定自定义的jar文件路径
from enjoy import Enjoy
if __name__ == "__main__":
# 1. 配置参数(需配置jar路径和模板路径)
JAR_PATH = "enjoy-5.2.2.jar" # enjoy-5.2.2.jar的绝对/相对路径
TEMPLATE_BASE_PATH = "./templates" # 模板文件所在目录(如index.html放在这个目录下)
# 2. 创建Enjoy实例(初始化Engine)
try:
enjoy = Enjoy(
jar_path=JAR_PATH,
template_base_path=TEMPLATE_BASE_PATH
)
# 3. 准备模板参数
render_data = {
"name": "JFinal Enjoy 5.2.2测试",
"hobbies": ["Python调用Java", "模板渲染", "跨语言开发"],
"user": {"age": 25, "gender": "男"}
}
# 4. 渲染模板(tempStr是模板文件名,相对于TEMPLATE_BASE_PATH)
result = enjoy.render(
tempStr="index.html", # 模板文件:./templates/index.html
data=render_data # 渲染数据(Python字典)
)
# 5. 输出结果
print("\n=== 模板渲染结果 ===")
print(result)
except RuntimeError as e:
print(f"\n执行失败: {e}")
finally:
# 6. 关闭资源
if 'enjoy' in locals():
enjoy.close()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_enjoy-0.1.2.tar.gz
(276.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
py_enjoy-0.1.2-py3-none-any.whl
(274.9 kB
view details)
File details
Details for the file py_enjoy-0.1.2.tar.gz.
File metadata
- Download URL: py_enjoy-0.1.2.tar.gz
- Upload date:
- Size: 276.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c92f8600bf5076f7860df00611dd7f3fa2da5db821e0571c27fb867d3b5026b
|
|
| MD5 |
0336bce36cd73591b2bf2ce8d8d88ce4
|
|
| BLAKE2b-256 |
a64b18c89685286dd40532c60e99735027070d6a3f90367a7940b66ba833c442
|
File details
Details for the file py_enjoy-0.1.2-py3-none-any.whl.
File metadata
- Download URL: py_enjoy-0.1.2-py3-none-any.whl
- Upload date:
- Size: 274.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02aabf8a9dca87648954bf0db8c938df8195df54aee24ae1e3cff4a30d51d918
|
|
| MD5 |
d981c07f12b587f44fdd1445dbd53cb0
|
|
| BLAKE2b-256 |
dbc220e60a5a985d6b39bce95b1308d56b21eaa4950a7ede5722cb816d0f36ce
|