Play Framework新增子页面方法

Play框架路由与视图配置
本文详细介绍了如何在Play框架中配置路由和视图,包括添加新的HTTP处理方法、创建对应的视图文件以及在路由文件中进行配置。通过实例演示了如何新增一个简单的/hello路由。

例如我想增加

http://localhost:9000/hello

首先为Application.java新增一个方法

1 public static void hello() {
2         render();
3     }

之后在/app/views/Application下新增hello.html文件

最后配置conf/routes新增
GET     /hello                                      Application.hello

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET     /                                       Application.index
GET     /hello                                      Application.hello

# Ignore favicon requests
GET     /favicon.ico                            404

# Map static resources from the /app/public folder to the /public path
GET     /public/                                staticDir:public

# Catch all
*       /{controller}/{action}                  {controller}.{action}

之后重新启动项目,即可成功

 

转载于:https://www.cnblogs.com/xfww/p/10530220.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值