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.4.tar.gz
(277.1 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.4-py3-none-any.whl
(276.2 kB
view details)
File details
Details for the file py_enjoy-0.1.4.tar.gz.
File metadata
- Download URL: py_enjoy-0.1.4.tar.gz
- Upload date:
- Size: 277.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d99890363658a08094649dde845a8eb6ec306021337a7b9e54f89a90765d4208
|
|
| MD5 |
9a978e54ddf6923ee1f595578d1283c3
|
|
| BLAKE2b-256 |
cf616b815c6c2ab3495fd93fa9dcbbba0b1cbb6e8a5898891293dcae7336ef95
|
File details
Details for the file py_enjoy-0.1.4-py3-none-any.whl.
File metadata
- Download URL: py_enjoy-0.1.4-py3-none-any.whl
- Upload date:
- Size: 276.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
495b18987ae82651d72fb13819bfd2dd1d96e59440e8ea001750a57cd6aa570a
|
|
| MD5 |
67db9b3d0e56e34eadcb51d164c3e82b
|
|
| BLAKE2b-256 |
50a1f3728d5ddefcfca0c863f74111b219407044394d835702fc45b04f8b1ec9
|