4

此代码工作正常:

在控制器中:

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))

在视图中:

@(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)

但是当我尝试向控制器添加一个变量并像这样查看时:

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 

我究竟做错了什么?

4

1 回答 1

7

您可以传递给模板的参数数量是有限制的。当您添加另一个参数时,您已经超过了它。

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

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

于 2012-07-25T17:37:23.737 回答