1

我已经建立了我的网址:

#url = /index/test/argument/second
# Maps to the Index handler's test method and passes in the optional arguments 'argument' and 'second' 

# So the handler function looks like this:

def test(argument=None,second=None):
   print 'test'

我正在使用来自 webapp2 的 strict_slash,因此带有斜杠的处理程序会被重定向到没有斜杠的处理程序。

#url = /index/ redirects perfectly to /index
#url = /index/test/ # KEYERROR!!

因此,即使 index/test 在 index/test/second 之前路由,webapp2 也会忽略尾随斜杠的重定向并返回错误,因为它正在寻找(太难)第二个参数。我认为它应该认识到没有第二个参数,所以遵循 strict_slash 重定向路线。

这适用于所有情况,但参数传递除外。任何见解,任何人?

4

1 回答 1

1

要解决此问题,您只需为路线设置唯一名称参数。

于 2013-05-18T13:08:55.197 回答