zoukankan      html  css  js  c++  java
  • 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>





  • 相关阅读:
    国内好用的maven仓库,添加到本地nexus中
    02 介绍
    11 jsp脚本调用java代码
    12 jsp page 指令
    14 javaBean 组件
    13 jsp include
    01 Servlet & Jsp 技术概述
    pl/sql 实例精解 05
    pl/sql 实例精解 06
    pl/sql 实例精解 08
  • 原文地址:https://www.cnblogs.com/samlee/p/2215988.html
Copyright © 2011-2022 走看看