Scala Play传递变量以查看不起作用

标签 scala playframework

这段代码工作正常:

在 Controller 中:

Ok(views.html.payment(message,test,x_card_num,x_exp_date,exp_year,exp_month,x_card_code,x_first_name,x_last_name,x_address,x_city,x_state,x_zip,save_account,product_array,x_amount,products_json,auth_net_customer_profile_id,auth_net_payment_profile_id,customer_id))

在 View 中:
@(message: String, test: String, x_card_num: String, x_exp_date: String,exp_year: String, exp_month: String, x_card_code: String, x_first_name: String, x_last_name: String, x_address: String, x_city: String, x_state: String, x_zip: String, save_account: String, product_array: Map[String,Map[String,Any]], x_amount: String, products_json: String, auth_net_customer_profile_id: String,auth_net_payment_profile_id: String,customer_id: String)

但是当我尝试向 Controller 添加另一个变量并查看如下时:
Ok(views.html.payment(message,test,x_card_num,x_exp_date,exp_year,exp_month,x_card_code,x_first_name,x_last_name,x_address,x_city,x_state,x_zip,save_account,product_array,x_amount,products_json,auth_net_customer_profile_id,auth_net_payment_profile_id,customer_id,saved_payments_xml))


@(message: String, test: String, x_card_num: String, x_exp_date: String,exp_year: String, exp_month: String, x_card_code: String, x_first_name: String, x_last_name: String, x_address: String, x_city: String, x_state: String, x_zip: String, save_account: String, product_array: Map[String,Map[String,Any]], x_amount: String, products_json: String, auth_net_customer_profile_id: String,auth_net_payment_profile_id: String,customer_id: String, saved_payments_xml: String)

它给了我这个错误:
missing parameter type 

我究竟做错了什么?

最佳答案

您可以传递给 template 的参数数量有限制.当您添加另一个参数时,您已经超出了它。

这是一个未记录且相当任意的限制,这是从模板生成代码的工作方式的结果。这可以说是一个错误,但不是我会修复的错误,因为没有人需要这么多参数,而拥有这么多参数会降低代码的可读性。

最好的解决方法是重构,例如通过创建一些案例类来表示模型中的 Card 和 Address,然后将它们传递进来。

关于Scala Play传递变量以查看不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11654992/

相关文章:

scala - 通过 libraryDependencies 和 sbt 插件添加依赖项有什么区别?

jquery - 如何通过 AJAX 到 HTTP 请求 JSON 来预填充 Web 表单?

java - 如何在eclipse中运行play framework单元测试

json - FlexJSON 无法反序列化日期

Scala 和 Play : stream files to S3 using iteratees

java - play framework - 在路由中绑定(bind)枚举

python - Scala 中的斑马拼图

scala - 如何用 Scala 绘制位图?

scala - 与 IO monads 的普通旧特征相比,Free monads 有什么优势?

scala - 使用 scala 从 FilePath 中提取文件夹名称和文件名