• web.py的input获取问题


    1. 问题现象, 通过web.input获取Form提交的请求, 发现后台并没有获取请求,并且通过firebug看到的content-length为0

    web.py 代码如下:

      

    import web
    urls = (
    '/','Index',
    '/commit', 'Commit'
    )

    render = web.template.render('templates')
    app = web.application(urls, globals())

    class Index:
    def GET(self):
    return render.login()

    class Commit:
    def POST(self):
    print web.input()
    return 'hello world'

    if __name__ == "__main__":
    app.run()

    部分html代码如下:

    <form method="POST" action="/commit">
    username:<input type="text" id="un" value=""/>
    passwd:<input type="password" id="pwd" value=""/>
    <input type="submit" value="submit"/>
    </form>

    问题解决:

    原来web.input获取的数据都是通过name来获取的,而我这里html页面里头都是用的id,修改html页面如下即可

    <form method="POST" action="/commit">
    username:<input type="text" name="un" value=""/>
    passwd:<input type="password" name="pwd" value=""/>
    <input type="submit" value="submit"/>
    </form>





  • 相关阅读:
    spring源码阅读(一)
    多线程学习(十)
    多线程学习(九)
    多线程学习(八)
    多线程学习(七)
    多线程学习(六)
    多线程学习(五)
    多线程学习(四)
    matlab-table
    Matlab
  • 原文地址:https://www.cnblogs.com/samlee/p/2215988.html
Copyright © 2020-2023  润新知