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)

しかし、コントローラーにもう1つの変数を追加して、次のように表示しようとすると、次のようになります。

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

テンプレートに渡すことができるパラメータの数には制限があります。別のパラメータを追加すると、それを超えました。

これは文書化されていないかなり恣意的な制限であり、テンプレートからのコード生成がどのように機能するかの結果です。これは間違いなくバグですが、これほど多くのパラメーターを必要とする人は誰もいないため、私が修正するバグではありません。これほど多くのパラメーターがあると、コードがはるかに読みにくくなります。

ここでの最善の解決策は、たとえば、モデル内のカードとアドレスを表すいくつかのケースクラスを作成し、代わりにそれらを渡すことによってリファクタリングすることです。

于 2012-07-25T17:37:23.737 に答える