如何将龙卷风中的参数传递给html文件?

问题描述 投票:-1回答:1

我已经共享了我的代码的一部分,在类'Room'中,变量'nw'具有查询字符串值。现在,我希望html文件动态地用查询字符串值自动填充'nw'字段。我怎么做得到那个?self.get_namespaces有帮助吗?

    class Room(tornado.web.RequestHandler):
    def get(self):
       nw=self.get_argument("nw")
       print(nw)
       self.render("RoomPost.html")  

class static(tornado.web.RequestHandler):
    def get(self,key):
           iname="static/" +key
    print iname
              self.render(iname)        
settings = {
    'debug': True,
    'static_path': 'static'}

application = tornado.web.Application([

        (r"/room",Room ),

        #(r"/static/(.*)",static)
        ], **settings)
if __name__ == "__main__":
    application.listen(5500)
tornado.ioloop.IOLoop.instance().start()

以下是html文件

<html>
<head>
<link rel="stylesheet" href="{{ static_url("css/registration.css")}} />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

</head>
<body>
<c:import url="InnerHeader.js"></c:import>
<br><br><br>

<center>
    <form action="/room" method="post" >
    <fieldset>
        <legend>
            <b1>Room Add</b1>
        </legend>
        <table class="registerTable">
            <tr>
                <td>Name of NW/Name of Home</td>
                <td><input type="text" name="nw" placeholder="Kfx-Home"
                    maxlength="15" size="30" autofocus required/></td>
            </tr>

                <tr>
                <td colspan="2" align="center" > &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
                <input type="submit"     value="  Submit  " /></td>
                </tr>

        </table>
        </fieldset>
    </form>
</center>

python html jsp web tornado
1个回答
0
投票

以下链接帮助我找到了答案:

How to pass arguments from tornado to a js file but not html?

我在tornado脚本中添加了self.render(“RoomPost.jsp”,nw = nw),并在.jsp脚本中自动调焦所需的值=“{{nw}}”readonly />。

© www.soinside.com 2019 - 2024. All rights reserved.