1

https://<server_name>/getparam?h1=hello&h2=goodbye

get 'getparam' => sub {
  my $c = shift;
  print $c->param('h1') . "\n";       # THIS WORKS AS I WOULD EXPECT
  my @list_of_all_params = $c->param; # DOES NOT WORK and THIS IS WHAT I WOULD LIKE TO MAKE WORK
  return 1;
};

所以我真正想要的是@list_of_all_params 包含“h1”和“h2”这是使用传递的参数: https://<server_name>/getparam?h1=hello&h2=goodbye

提前感谢大家!

4

1 回答 1

3

也许

  # Dump the query as a hash
  warn Data::Dumper->new([\$c->req()->params()->to_hash()],[qw(*text)])->Dump(),' ';
  # Dump the names in the query
  warn Data::Dumper->Dump([\$c->req()->params()->names],[qw(*params)]),' ';
  # Dump the values for each key of the query
  for my $key (@{$c->req()->params()->names}) {
       warn Data::Dumper->new([\$key,\$c->req()->every_param($key)],[qw(*key *values)])->Dump(),' ';
       };
于 2021-01-16T20:52:27.097 回答