首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
推荐学习书目
›
Learn Python the Hard Way
Python Sites
›
PyPI
- Python Package Index
›
http://diveintopython.org/toc/index.html
›
Pocoo
值得关注的项目
›
PyPy
›
Celery
›
Jinja2
›
Read the Docs
›
gevent
›
pyenv
›
virtualenv
›
Stackless Python
›
Beautiful Soup
›
结巴中文分词
›
Green Unicorn
›
Sentry
›
Shovel
›
Pyflakes
›
pytest
Python 编程
›
pep8 Checker
Styles
›
PEP 8
›
Google Python Style Guide
›
Code Style from The Hitchhiker's Guide
V2EX
›
Python
请教web.py中自定义404错误页的问题。
paloalto
·
2012 年 12 月 5 日
· 3271 次点击
这是一个创建于 4859 天前的主题,其中的信息可能已经有所发展或是发生改变。
代码如下:
访问
http://0.0.0.0:8080/post/123test
时,因为url不匹配,会跳转到我自定义的404页面:view.error();
但是访问
http://0.0.0.0:8080/post/123
这种url,如果ID为123的post不存在,就直接在页面中显示 “404 Not Found”了,没法跳转到我自定义的404错误页面。
请问怎么才能让这两种情况都跳转到我自定义的404错误页面呢?
自定义
访问
5 条回复
•
1970-01-01 08:00:00 +08:00
1
Js
2012 年 12 月 5 日
http://lmgtfy.com/?q=webpy+raise+404
2
tokki
2012 年 12 月 5 日
ls好黑
3
paloalto
OP
2012 年 12 月 5 日
@
Js
谢谢你的回复。我是google了“
web.py
自定义 404”之后,按照google搜索结果中的web.py的教程写的. raise 404我已经做到了,但是出现了两种404的情况,请问是何原因呢?
4
paloalto
OP
2012 年 12 月 5 日
@
paloalto
哈哈,我知道原因了。
5
paloalto
OP
2012 年 12 月 5 日
需要在app.controllers.post.post_show中写上 raise web.notfound() :
def GET(self,node_id):
----if node:
--------return view.node_show()
----else:
--------raise web.notfound()
关于
·
帮助文档
·
自助推广系统
·
博客
·
API
·
FAQ
·
Solana
·
1654 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 27ms ·
UTC 16:27
·
PVG 00:27
·
LAX 09:27
·
JFK 12:27
♥ Do have faith in what you're doing.
❯