0

我正在尝试使以下链接正常工作: http://localhost:8001/name/jason/grey

和路线定义:

{"/name/([a-zA-Z]+)/([a-zA-Z]+)", [{controller, "stuff"}, {action, "getStudentNames"}, [{firstname, '$1'}, {lastname, '$2'}]]}.

然后在我的控制器中

getStudentNames('GET', [FirstName, LastName])->
  {output, "ok"}.

我收到以下错误消息

CRASH REPORT Process <0.313.0> with 0 neighbours exited with reason: no function clause matching boss_router_controller:'-index_and_extract_params/1-fun-0-'([{firstname,'$1'},{lastname,'$2'}], []) line 258 in gen_server:terminate/7 line 812

似乎我的路线定义不正确,有什么帮助吗?

4

1 回答 1

0

终于让它工作了,以防万一有人遇到同样的问题。不要在路由定义中使用元组列表来定义参数,而是使用以逗号分隔的元组,例如

{"/name/([a-zA-Z]+)/([a-zA-Z]+)", [{controller, "stuff"}, {action, "getStudentNames"}, {firstname, '$1'}, {lastname, '$2'}]}.
于 2016-12-06T11:59:22.747 回答